{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "'''\n",
    "【课程3.13】  表格样式创建\n",
    "\n",
    "表格视觉样式：Dataframe.style → 返回pandas.Styler对象的属性，具有格式化和显示Dataframe的有用方法\n",
    "\n",
    "样式创建：\n",
    "① Styler.applymap：elementwise → 按元素方式处理Dataframe\n",
    "② Styler.apply：column- / row- / table-wise → 按行/列处理Dataframe\n",
    " \n",
    "'''"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "% matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<pandas.formats.style.Styler object at 0x0000000009789CF8> <class 'pandas.formats.style.Styler'>\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "\n",
       "        <style  type=\"text/css\" >\n",
       "        \n",
       "        \n",
       "        </style>\n",
       "\n",
       "        <table id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810d\" None>\n",
       "        \n",
       "\n",
       "        <thead>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th class=\"blank\">\n",
       "                \n",
       "                <th class=\"col_heading level0 col0\">a\n",
       "                \n",
       "                <th class=\"col_heading level0 col1\">b\n",
       "                \n",
       "                <th class=\"col_heading level0 col2\">c\n",
       "                \n",
       "                <th class=\"col_heading level0 col3\">d\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "        </thead>\n",
       "        <tbody>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810d\" class=\"row_heading level3 row0\">\n",
       "                    0\n",
       "                \n",
       "                <td id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810drow0_col0\" class=\"data row0 col0\">\n",
       "                    1.1215\n",
       "                \n",
       "                <td id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810drow0_col1\" class=\"data row0 col1\">\n",
       "                    -1.38757\n",
       "                \n",
       "                <td id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810drow0_col2\" class=\"data row0 col2\">\n",
       "                    -0.694214\n",
       "                \n",
       "                <td id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810drow0_col3\" class=\"data row0 col3\">\n",
       "                    -0.887584\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810d\" class=\"row_heading level3 row1\">\n",
       "                    1\n",
       "                \n",
       "                <td id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810drow1_col0\" class=\"data row1 col0\">\n",
       "                    0.254148\n",
       "                \n",
       "                <td id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810drow1_col1\" class=\"data row1 col1\">\n",
       "                    -0.578241\n",
       "                \n",
       "                <td id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810drow1_col2\" class=\"data row1 col2\">\n",
       "                    0.336016\n",
       "                \n",
       "                <td id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810drow1_col3\" class=\"data row1 col3\">\n",
       "                    -2.05696\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810d\" class=\"row_heading level3 row2\">\n",
       "                    2\n",
       "                \n",
       "                <td id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810drow2_col0\" class=\"data row2 col0\">\n",
       "                    1.80943\n",
       "                \n",
       "                <td id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810drow2_col1\" class=\"data row2 col1\">\n",
       "                    -0.524478\n",
       "                \n",
       "                <td id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810drow2_col2\" class=\"data row2 col2\">\n",
       "                    0.24831\n",
       "                \n",
       "                <td id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810drow2_col3\" class=\"data row2 col3\">\n",
       "                    -1.01775\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810d\" class=\"row_heading level3 row3\">\n",
       "                    3\n",
       "                \n",
       "                <td id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810drow3_col0\" class=\"data row3 col0\">\n",
       "                    0.585044\n",
       "                \n",
       "                <td id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810drow3_col1\" class=\"data row3 col1\">\n",
       "                    0.944626\n",
       "                \n",
       "                <td id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810drow3_col2\" class=\"data row3 col2\">\n",
       "                    0.650761\n",
       "                \n",
       "                <td id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810drow3_col3\" class=\"data row3 col3\">\n",
       "                    0.270653\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810d\" class=\"row_heading level3 row4\">\n",
       "                    4\n",
       "                \n",
       "                <td id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810drow4_col0\" class=\"data row4 col0\">\n",
       "                    1.93673\n",
       "                \n",
       "                <td id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810drow4_col1\" class=\"data row4 col1\">\n",
       "                    -0.125753\n",
       "                \n",
       "                <td id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810drow4_col2\" class=\"data row4 col2\">\n",
       "                    -0.0392093\n",
       "                \n",
       "                <td id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810drow4_col3\" class=\"data row4 col3\">\n",
       "                    -0.0418587\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810d\" class=\"row_heading level3 row5\">\n",
       "                    5\n",
       "                \n",
       "                <td id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810drow5_col0\" class=\"data row5 col0\">\n",
       "                    -0.508527\n",
       "                \n",
       "                <td id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810drow5_col1\" class=\"data row5 col1\">\n",
       "                    0.468058\n",
       "                \n",
       "                <td id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810drow5_col2\" class=\"data row5 col2\">\n",
       "                    -0.475535\n",
       "                \n",
       "                <td id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810drow5_col3\" class=\"data row5 col3\">\n",
       "                    -0.0566373\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810d\" class=\"row_heading level3 row6\">\n",
       "                    6\n",
       "                \n",
       "                <td id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810drow6_col0\" class=\"data row6 col0\">\n",
       "                    1.18967\n",
       "                \n",
       "                <td id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810drow6_col1\" class=\"data row6 col1\">\n",
       "                    0.0861624\n",
       "                \n",
       "                <td id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810drow6_col2\" class=\"data row6 col2\">\n",
       "                    0.509731\n",
       "                \n",
       "                <td id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810drow6_col3\" class=\"data row6 col3\">\n",
       "                    0.107588\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810d\" class=\"row_heading level3 row7\">\n",
       "                    7\n",
       "                \n",
       "                <td id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810drow7_col0\" class=\"data row7 col0\">\n",
       "                    0.251497\n",
       "                \n",
       "                <td id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810drow7_col1\" class=\"data row7 col1\">\n",
       "                    -2.65956\n",
       "                \n",
       "                <td id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810drow7_col2\" class=\"data row7 col2\">\n",
       "                    0.803005\n",
       "                \n",
       "                <td id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810drow7_col3\" class=\"data row7 col3\">\n",
       "                    -0.0121781\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810d\" class=\"row_heading level3 row8\">\n",
       "                    8\n",
       "                \n",
       "                <td id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810drow8_col0\" class=\"data row8 col0\">\n",
       "                    1.96226\n",
       "                \n",
       "                <td id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810drow8_col1\" class=\"data row8 col1\">\n",
       "                    -1.22001\n",
       "                \n",
       "                <td id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810drow8_col2\" class=\"data row8 col2\">\n",
       "                    -1.02514\n",
       "                \n",
       "                <td id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810drow8_col3\" class=\"data row8 col3\">\n",
       "                    -0.922657\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810d\" class=\"row_heading level3 row9\">\n",
       "                    9\n",
       "                \n",
       "                <td id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810drow9_col0\" class=\"data row9 col0\">\n",
       "                    0.706176\n",
       "                \n",
       "                <td id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810drow9_col1\" class=\"data row9 col1\">\n",
       "                    -1.28399\n",
       "                \n",
       "                <td id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810drow9_col2\" class=\"data row9 col2\">\n",
       "                    0.323935\n",
       "                \n",
       "                <td id=\"T_ff6badd2_f2f8_11e7_a3ad_240a64de810drow9_col3\" class=\"data row9 col3\">\n",
       "                    -1.03275\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "        </tbody>\n",
       "        </table>\n",
       "        "
      ],
      "text/plain": [
       "<pandas.formats.style.Styler at 0x9789cf8>"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 样式\n",
    "\n",
    "df = pd.DataFrame(np.random.randn(10,4),columns=['a','b','c','d'])\n",
    "sty = df.style\n",
    "print(sty,type(sty))\n",
    "# 查看样式类型\n",
    "\n",
    "sty\n",
    "# 显示样式"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "        <style  type=\"text/css\" >\n",
       "        \n",
       "        \n",
       "            #T_004436ae_f2f9_11e7_8c7b_240a64de810drow0_col0 {\n",
       "            \n",
       "                color: black;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_004436ae_f2f9_11e7_8c7b_240a64de810drow0_col1 {\n",
       "            \n",
       "                color: red;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_004436ae_f2f9_11e7_8c7b_240a64de810drow0_col2 {\n",
       "            \n",
       "                color: red;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_004436ae_f2f9_11e7_8c7b_240a64de810drow0_col3 {\n",
       "            \n",
       "                color: red;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_004436ae_f2f9_11e7_8c7b_240a64de810drow1_col0 {\n",
       "            \n",
       "                color: black;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_004436ae_f2f9_11e7_8c7b_240a64de810drow1_col1 {\n",
       "            \n",
       "                color: red;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_004436ae_f2f9_11e7_8c7b_240a64de810drow1_col2 {\n",
       "            \n",
       "                color: black;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_004436ae_f2f9_11e7_8c7b_240a64de810drow1_col3 {\n",
       "            \n",
       "                color: red;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_004436ae_f2f9_11e7_8c7b_240a64de810drow2_col0 {\n",
       "            \n",
       "                color: black;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_004436ae_f2f9_11e7_8c7b_240a64de810drow2_col1 {\n",
       "            \n",
       "                color: red;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_004436ae_f2f9_11e7_8c7b_240a64de810drow2_col2 {\n",
       "            \n",
       "                color: black;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_004436ae_f2f9_11e7_8c7b_240a64de810drow2_col3 {\n",
       "            \n",
       "                color: red;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_004436ae_f2f9_11e7_8c7b_240a64de810drow3_col0 {\n",
       "            \n",
       "                color: black;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_004436ae_f2f9_11e7_8c7b_240a64de810drow3_col1 {\n",
       "            \n",
       "                color: black;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_004436ae_f2f9_11e7_8c7b_240a64de810drow3_col2 {\n",
       "            \n",
       "                color: black;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_004436ae_f2f9_11e7_8c7b_240a64de810drow3_col3 {\n",
       "            \n",
       "                color: black;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_004436ae_f2f9_11e7_8c7b_240a64de810drow4_col0 {\n",
       "            \n",
       "                color: black;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_004436ae_f2f9_11e7_8c7b_240a64de810drow4_col1 {\n",
       "            \n",
       "                color: red;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_004436ae_f2f9_11e7_8c7b_240a64de810drow4_col2 {\n",
       "            \n",
       "                color: red;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_004436ae_f2f9_11e7_8c7b_240a64de810drow4_col3 {\n",
       "            \n",
       "                color: red;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_004436ae_f2f9_11e7_8c7b_240a64de810drow5_col0 {\n",
       "            \n",
       "                color: red;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_004436ae_f2f9_11e7_8c7b_240a64de810drow5_col1 {\n",
       "            \n",
       "                color: black;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_004436ae_f2f9_11e7_8c7b_240a64de810drow5_col2 {\n",
       "            \n",
       "                color: red;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_004436ae_f2f9_11e7_8c7b_240a64de810drow5_col3 {\n",
       "            \n",
       "                color: red;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_004436ae_f2f9_11e7_8c7b_240a64de810drow6_col0 {\n",
       "            \n",
       "                color: black;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_004436ae_f2f9_11e7_8c7b_240a64de810drow6_col1 {\n",
       "            \n",
       "                color: black;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_004436ae_f2f9_11e7_8c7b_240a64de810drow6_col2 {\n",
       "            \n",
       "                color: black;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_004436ae_f2f9_11e7_8c7b_240a64de810drow6_col3 {\n",
       "            \n",
       "                color: black;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_004436ae_f2f9_11e7_8c7b_240a64de810drow7_col0 {\n",
       "            \n",
       "                color: black;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_004436ae_f2f9_11e7_8c7b_240a64de810drow7_col1 {\n",
       "            \n",
       "                color: red;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_004436ae_f2f9_11e7_8c7b_240a64de810drow7_col2 {\n",
       "            \n",
       "                color: black;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_004436ae_f2f9_11e7_8c7b_240a64de810drow7_col3 {\n",
       "            \n",
       "                color: red;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_004436ae_f2f9_11e7_8c7b_240a64de810drow8_col0 {\n",
       "            \n",
       "                color: black;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_004436ae_f2f9_11e7_8c7b_240a64de810drow8_col1 {\n",
       "            \n",
       "                color: red;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_004436ae_f2f9_11e7_8c7b_240a64de810drow8_col2 {\n",
       "            \n",
       "                color: red;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_004436ae_f2f9_11e7_8c7b_240a64de810drow8_col3 {\n",
       "            \n",
       "                color: red;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_004436ae_f2f9_11e7_8c7b_240a64de810drow9_col0 {\n",
       "            \n",
       "                color: black;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_004436ae_f2f9_11e7_8c7b_240a64de810drow9_col1 {\n",
       "            \n",
       "                color: red;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_004436ae_f2f9_11e7_8c7b_240a64de810drow9_col2 {\n",
       "            \n",
       "                color: black;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_004436ae_f2f9_11e7_8c7b_240a64de810drow9_col3 {\n",
       "            \n",
       "                color: red;\n",
       "            \n",
       "            }\n",
       "        \n",
       "        </style>\n",
       "\n",
       "        <table id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810d\" None>\n",
       "        \n",
       "\n",
       "        <thead>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th class=\"blank\">\n",
       "                \n",
       "                <th class=\"col_heading level0 col0\">a\n",
       "                \n",
       "                <th class=\"col_heading level0 col1\">b\n",
       "                \n",
       "                <th class=\"col_heading level0 col2\">c\n",
       "                \n",
       "                <th class=\"col_heading level0 col3\">d\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "        </thead>\n",
       "        <tbody>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810d\" class=\"row_heading level3 row0\">\n",
       "                    0\n",
       "                \n",
       "                <td id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810drow0_col0\" class=\"data row0 col0\">\n",
       "                    1.1215\n",
       "                \n",
       "                <td id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810drow0_col1\" class=\"data row0 col1\">\n",
       "                    -1.38757\n",
       "                \n",
       "                <td id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810drow0_col2\" class=\"data row0 col2\">\n",
       "                    -0.694214\n",
       "                \n",
       "                <td id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810drow0_col3\" class=\"data row0 col3\">\n",
       "                    -0.887584\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810d\" class=\"row_heading level3 row1\">\n",
       "                    1\n",
       "                \n",
       "                <td id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810drow1_col0\" class=\"data row1 col0\">\n",
       "                    0.254148\n",
       "                \n",
       "                <td id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810drow1_col1\" class=\"data row1 col1\">\n",
       "                    -0.578241\n",
       "                \n",
       "                <td id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810drow1_col2\" class=\"data row1 col2\">\n",
       "                    0.336016\n",
       "                \n",
       "                <td id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810drow1_col3\" class=\"data row1 col3\">\n",
       "                    -2.05696\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810d\" class=\"row_heading level3 row2\">\n",
       "                    2\n",
       "                \n",
       "                <td id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810drow2_col0\" class=\"data row2 col0\">\n",
       "                    1.80943\n",
       "                \n",
       "                <td id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810drow2_col1\" class=\"data row2 col1\">\n",
       "                    -0.524478\n",
       "                \n",
       "                <td id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810drow2_col2\" class=\"data row2 col2\">\n",
       "                    0.24831\n",
       "                \n",
       "                <td id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810drow2_col3\" class=\"data row2 col3\">\n",
       "                    -1.01775\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810d\" class=\"row_heading level3 row3\">\n",
       "                    3\n",
       "                \n",
       "                <td id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810drow3_col0\" class=\"data row3 col0\">\n",
       "                    0.585044\n",
       "                \n",
       "                <td id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810drow3_col1\" class=\"data row3 col1\">\n",
       "                    0.944626\n",
       "                \n",
       "                <td id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810drow3_col2\" class=\"data row3 col2\">\n",
       "                    0.650761\n",
       "                \n",
       "                <td id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810drow3_col3\" class=\"data row3 col3\">\n",
       "                    0.270653\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810d\" class=\"row_heading level3 row4\">\n",
       "                    4\n",
       "                \n",
       "                <td id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810drow4_col0\" class=\"data row4 col0\">\n",
       "                    1.93673\n",
       "                \n",
       "                <td id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810drow4_col1\" class=\"data row4 col1\">\n",
       "                    -0.125753\n",
       "                \n",
       "                <td id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810drow4_col2\" class=\"data row4 col2\">\n",
       "                    -0.0392093\n",
       "                \n",
       "                <td id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810drow4_col3\" class=\"data row4 col3\">\n",
       "                    -0.0418587\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810d\" class=\"row_heading level3 row5\">\n",
       "                    5\n",
       "                \n",
       "                <td id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810drow5_col0\" class=\"data row5 col0\">\n",
       "                    -0.508527\n",
       "                \n",
       "                <td id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810drow5_col1\" class=\"data row5 col1\">\n",
       "                    0.468058\n",
       "                \n",
       "                <td id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810drow5_col2\" class=\"data row5 col2\">\n",
       "                    -0.475535\n",
       "                \n",
       "                <td id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810drow5_col3\" class=\"data row5 col3\">\n",
       "                    -0.0566373\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810d\" class=\"row_heading level3 row6\">\n",
       "                    6\n",
       "                \n",
       "                <td id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810drow6_col0\" class=\"data row6 col0\">\n",
       "                    1.18967\n",
       "                \n",
       "                <td id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810drow6_col1\" class=\"data row6 col1\">\n",
       "                    0.0861624\n",
       "                \n",
       "                <td id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810drow6_col2\" class=\"data row6 col2\">\n",
       "                    0.509731\n",
       "                \n",
       "                <td id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810drow6_col3\" class=\"data row6 col3\">\n",
       "                    0.107588\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810d\" class=\"row_heading level3 row7\">\n",
       "                    7\n",
       "                \n",
       "                <td id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810drow7_col0\" class=\"data row7 col0\">\n",
       "                    0.251497\n",
       "                \n",
       "                <td id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810drow7_col1\" class=\"data row7 col1\">\n",
       "                    -2.65956\n",
       "                \n",
       "                <td id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810drow7_col2\" class=\"data row7 col2\">\n",
       "                    0.803005\n",
       "                \n",
       "                <td id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810drow7_col3\" class=\"data row7 col3\">\n",
       "                    -0.0121781\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810d\" class=\"row_heading level3 row8\">\n",
       "                    8\n",
       "                \n",
       "                <td id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810drow8_col0\" class=\"data row8 col0\">\n",
       "                    1.96226\n",
       "                \n",
       "                <td id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810drow8_col1\" class=\"data row8 col1\">\n",
       "                    -1.22001\n",
       "                \n",
       "                <td id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810drow8_col2\" class=\"data row8 col2\">\n",
       "                    -1.02514\n",
       "                \n",
       "                <td id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810drow8_col3\" class=\"data row8 col3\">\n",
       "                    -0.922657\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810d\" class=\"row_heading level3 row9\">\n",
       "                    9\n",
       "                \n",
       "                <td id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810drow9_col0\" class=\"data row9 col0\">\n",
       "                    0.706176\n",
       "                \n",
       "                <td id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810drow9_col1\" class=\"data row9 col1\">\n",
       "                    -1.28399\n",
       "                \n",
       "                <td id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810drow9_col2\" class=\"data row9 col2\">\n",
       "                    0.323935\n",
       "                \n",
       "                <td id=\"T_004436ae_f2f9_11e7_8c7b_240a64de810drow9_col3\" class=\"data row9 col3\">\n",
       "                    -1.03275\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "        </tbody>\n",
       "        </table>\n",
       "        "
      ],
      "text/plain": [
       "<pandas.formats.style.Styler at 0x9789e80>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 按元素处理样式：style.applymap()\n",
    "\n",
    "def color_neg_red(val):\n",
    "    if val < 0:\n",
    "        color = 'red'\n",
    "    else:\n",
    "        color = 'black'\n",
    "    return('color:%s' % color)\n",
    "df.style.applymap(color_neg_red)\n",
    "# 创建样式方法，使得小于0的数变成红色\n",
    "# style.applymap() → 自动调用其中的函数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "        <style  type=\"text/css\" >\n",
       "        \n",
       "        \n",
       "            #T_0104ca62_f2f9_11e7_ab63_240a64de810drow3_col1 {\n",
       "            \n",
       "                background-color:  yellow;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_0104ca62_f2f9_11e7_ab63_240a64de810drow7_col2 {\n",
       "            \n",
       "                background-color:  yellow;\n",
       "            \n",
       "            }\n",
       "        \n",
       "        </style>\n",
       "\n",
       "        <table id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810d\" None>\n",
       "        \n",
       "\n",
       "        <thead>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th class=\"blank\">\n",
       "                \n",
       "                <th class=\"col_heading level0 col0\">a\n",
       "                \n",
       "                <th class=\"col_heading level0 col1\">b\n",
       "                \n",
       "                <th class=\"col_heading level0 col2\">c\n",
       "                \n",
       "                <th class=\"col_heading level0 col3\">d\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "        </thead>\n",
       "        <tbody>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810d\" class=\"row_heading level3 row0\">\n",
       "                    0\n",
       "                \n",
       "                <td id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810drow0_col0\" class=\"data row0 col0\">\n",
       "                    1.1215\n",
       "                \n",
       "                <td id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810drow0_col1\" class=\"data row0 col1\">\n",
       "                    -1.38757\n",
       "                \n",
       "                <td id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810drow0_col2\" class=\"data row0 col2\">\n",
       "                    -0.694214\n",
       "                \n",
       "                <td id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810drow0_col3\" class=\"data row0 col3\">\n",
       "                    -0.887584\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810d\" class=\"row_heading level3 row1\">\n",
       "                    1\n",
       "                \n",
       "                <td id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810drow1_col0\" class=\"data row1 col0\">\n",
       "                    0.254148\n",
       "                \n",
       "                <td id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810drow1_col1\" class=\"data row1 col1\">\n",
       "                    -0.578241\n",
       "                \n",
       "                <td id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810drow1_col2\" class=\"data row1 col2\">\n",
       "                    0.336016\n",
       "                \n",
       "                <td id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810drow1_col3\" class=\"data row1 col3\">\n",
       "                    -2.05696\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810d\" class=\"row_heading level3 row2\">\n",
       "                    2\n",
       "                \n",
       "                <td id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810drow2_col0\" class=\"data row2 col0\">\n",
       "                    1.80943\n",
       "                \n",
       "                <td id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810drow2_col1\" class=\"data row2 col1\">\n",
       "                    -0.524478\n",
       "                \n",
       "                <td id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810drow2_col2\" class=\"data row2 col2\">\n",
       "                    0.24831\n",
       "                \n",
       "                <td id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810drow2_col3\" class=\"data row2 col3\">\n",
       "                    -1.01775\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810d\" class=\"row_heading level3 row3\">\n",
       "                    3\n",
       "                \n",
       "                <td id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810drow3_col0\" class=\"data row3 col0\">\n",
       "                    0.585044\n",
       "                \n",
       "                <td id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810drow3_col1\" class=\"data row3 col1\">\n",
       "                    0.944626\n",
       "                \n",
       "                <td id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810drow3_col2\" class=\"data row3 col2\">\n",
       "                    0.650761\n",
       "                \n",
       "                <td id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810drow3_col3\" class=\"data row3 col3\">\n",
       "                    0.270653\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810d\" class=\"row_heading level3 row4\">\n",
       "                    4\n",
       "                \n",
       "                <td id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810drow4_col0\" class=\"data row4 col0\">\n",
       "                    1.93673\n",
       "                \n",
       "                <td id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810drow4_col1\" class=\"data row4 col1\">\n",
       "                    -0.125753\n",
       "                \n",
       "                <td id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810drow4_col2\" class=\"data row4 col2\">\n",
       "                    -0.0392093\n",
       "                \n",
       "                <td id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810drow4_col3\" class=\"data row4 col3\">\n",
       "                    -0.0418587\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810d\" class=\"row_heading level3 row5\">\n",
       "                    5\n",
       "                \n",
       "                <td id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810drow5_col0\" class=\"data row5 col0\">\n",
       "                    -0.508527\n",
       "                \n",
       "                <td id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810drow5_col1\" class=\"data row5 col1\">\n",
       "                    0.468058\n",
       "                \n",
       "                <td id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810drow5_col2\" class=\"data row5 col2\">\n",
       "                    -0.475535\n",
       "                \n",
       "                <td id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810drow5_col3\" class=\"data row5 col3\">\n",
       "                    -0.0566373\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810d\" class=\"row_heading level3 row6\">\n",
       "                    6\n",
       "                \n",
       "                <td id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810drow6_col0\" class=\"data row6 col0\">\n",
       "                    1.18967\n",
       "                \n",
       "                <td id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810drow6_col1\" class=\"data row6 col1\">\n",
       "                    0.0861624\n",
       "                \n",
       "                <td id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810drow6_col2\" class=\"data row6 col2\">\n",
       "                    0.509731\n",
       "                \n",
       "                <td id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810drow6_col3\" class=\"data row6 col3\">\n",
       "                    0.107588\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810d\" class=\"row_heading level3 row7\">\n",
       "                    7\n",
       "                \n",
       "                <td id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810drow7_col0\" class=\"data row7 col0\">\n",
       "                    0.251497\n",
       "                \n",
       "                <td id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810drow7_col1\" class=\"data row7 col1\">\n",
       "                    -2.65956\n",
       "                \n",
       "                <td id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810drow7_col2\" class=\"data row7 col2\">\n",
       "                    0.803005\n",
       "                \n",
       "                <td id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810drow7_col3\" class=\"data row7 col3\">\n",
       "                    -0.0121781\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810d\" class=\"row_heading level3 row8\">\n",
       "                    8\n",
       "                \n",
       "                <td id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810drow8_col0\" class=\"data row8 col0\">\n",
       "                    1.96226\n",
       "                \n",
       "                <td id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810drow8_col1\" class=\"data row8 col1\">\n",
       "                    -1.22001\n",
       "                \n",
       "                <td id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810drow8_col2\" class=\"data row8 col2\">\n",
       "                    -1.02514\n",
       "                \n",
       "                <td id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810drow8_col3\" class=\"data row8 col3\">\n",
       "                    -0.922657\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810d\" class=\"row_heading level3 row9\">\n",
       "                    9\n",
       "                \n",
       "                <td id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810drow9_col0\" class=\"data row9 col0\">\n",
       "                    0.706176\n",
       "                \n",
       "                <td id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810drow9_col1\" class=\"data row9 col1\">\n",
       "                    -1.28399\n",
       "                \n",
       "                <td id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810drow9_col2\" class=\"data row9 col2\">\n",
       "                    0.323935\n",
       "                \n",
       "                <td id=\"T_0104ca62_f2f9_11e7_ab63_240a64de810drow9_col3\" class=\"data row9 col3\">\n",
       "                    -1.03275\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "        </tbody>\n",
       "        </table>\n",
       "        "
      ],
      "text/plain": [
       "<pandas.formats.style.Styler at 0x98787f0>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 按行/列处理样式：style.apply()\n",
    "\n",
    "def highlight_max(s):\n",
    "    is_max = s == s.max()\n",
    "    #print(is_max)\n",
    "    lst = []\n",
    "    for v in is_max:\n",
    "        if v:\n",
    "            lst.append('background-color: yellow')\n",
    "        else:\n",
    "            lst.append('')\n",
    "    return(lst)\n",
    "df.style.apply(highlight_max, axis = 0, subset = ['b','c'])\n",
    "# 创建样式方法，每列最大值填充黄色\n",
    "# axis：0为列，1为行，默认为0\n",
    "# subset：索引"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "        <style  type=\"text/css\" >\n",
       "        \n",
       "        \n",
       "            #T_01e5429a_f2f9_11e7_bfc9_240a64de810drow2_col1 {\n",
       "            \n",
       "                background-color:  yellow;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_01e5429a_f2f9_11e7_bfc9_240a64de810drow3_col1 {\n",
       "            \n",
       "                background-color:  yellow;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_01e5429a_f2f9_11e7_bfc9_240a64de810drow4_col3 {\n",
       "            \n",
       "                background-color:  yellow;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_01e5429a_f2f9_11e7_bfc9_240a64de810drow5_col1 {\n",
       "            \n",
       "                background-color:  yellow;\n",
       "            \n",
       "            }\n",
       "        \n",
       "        </style>\n",
       "\n",
       "        <table id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810d\" None>\n",
       "        \n",
       "\n",
       "        <thead>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th class=\"blank\">\n",
       "                \n",
       "                <th class=\"col_heading level0 col0\">a\n",
       "                \n",
       "                <th class=\"col_heading level0 col1\">b\n",
       "                \n",
       "                <th class=\"col_heading level0 col2\">c\n",
       "                \n",
       "                <th class=\"col_heading level0 col3\">d\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "        </thead>\n",
       "        <tbody>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810d\" class=\"row_heading level3 row0\">\n",
       "                    0\n",
       "                \n",
       "                <td id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810drow0_col0\" class=\"data row0 col0\">\n",
       "                    1.1215\n",
       "                \n",
       "                <td id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810drow0_col1\" class=\"data row0 col1\">\n",
       "                    -1.38757\n",
       "                \n",
       "                <td id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810drow0_col2\" class=\"data row0 col2\">\n",
       "                    -0.694214\n",
       "                \n",
       "                <td id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810drow0_col3\" class=\"data row0 col3\">\n",
       "                    -0.887584\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810d\" class=\"row_heading level3 row1\">\n",
       "                    1\n",
       "                \n",
       "                <td id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810drow1_col0\" class=\"data row1 col0\">\n",
       "                    0.254148\n",
       "                \n",
       "                <td id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810drow1_col1\" class=\"data row1 col1\">\n",
       "                    -0.578241\n",
       "                \n",
       "                <td id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810drow1_col2\" class=\"data row1 col2\">\n",
       "                    0.336016\n",
       "                \n",
       "                <td id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810drow1_col3\" class=\"data row1 col3\">\n",
       "                    -2.05696\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810d\" class=\"row_heading level3 row2\">\n",
       "                    2\n",
       "                \n",
       "                <td id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810drow2_col0\" class=\"data row2 col0\">\n",
       "                    1.80943\n",
       "                \n",
       "                <td id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810drow2_col1\" class=\"data row2 col1\">\n",
       "                    -0.524478\n",
       "                \n",
       "                <td id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810drow2_col2\" class=\"data row2 col2\">\n",
       "                    0.24831\n",
       "                \n",
       "                <td id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810drow2_col3\" class=\"data row2 col3\">\n",
       "                    -1.01775\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810d\" class=\"row_heading level3 row3\">\n",
       "                    3\n",
       "                \n",
       "                <td id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810drow3_col0\" class=\"data row3 col0\">\n",
       "                    0.585044\n",
       "                \n",
       "                <td id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810drow3_col1\" class=\"data row3 col1\">\n",
       "                    0.944626\n",
       "                \n",
       "                <td id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810drow3_col2\" class=\"data row3 col2\">\n",
       "                    0.650761\n",
       "                \n",
       "                <td id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810drow3_col3\" class=\"data row3 col3\">\n",
       "                    0.270653\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810d\" class=\"row_heading level3 row4\">\n",
       "                    4\n",
       "                \n",
       "                <td id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810drow4_col0\" class=\"data row4 col0\">\n",
       "                    1.93673\n",
       "                \n",
       "                <td id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810drow4_col1\" class=\"data row4 col1\">\n",
       "                    -0.125753\n",
       "                \n",
       "                <td id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810drow4_col2\" class=\"data row4 col2\">\n",
       "                    -0.0392093\n",
       "                \n",
       "                <td id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810drow4_col3\" class=\"data row4 col3\">\n",
       "                    -0.0418587\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810d\" class=\"row_heading level3 row5\">\n",
       "                    5\n",
       "                \n",
       "                <td id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810drow5_col0\" class=\"data row5 col0\">\n",
       "                    -0.508527\n",
       "                \n",
       "                <td id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810drow5_col1\" class=\"data row5 col1\">\n",
       "                    0.468058\n",
       "                \n",
       "                <td id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810drow5_col2\" class=\"data row5 col2\">\n",
       "                    -0.475535\n",
       "                \n",
       "                <td id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810drow5_col3\" class=\"data row5 col3\">\n",
       "                    -0.0566373\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810d\" class=\"row_heading level3 row6\">\n",
       "                    6\n",
       "                \n",
       "                <td id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810drow6_col0\" class=\"data row6 col0\">\n",
       "                    1.18967\n",
       "                \n",
       "                <td id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810drow6_col1\" class=\"data row6 col1\">\n",
       "                    0.0861624\n",
       "                \n",
       "                <td id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810drow6_col2\" class=\"data row6 col2\">\n",
       "                    0.509731\n",
       "                \n",
       "                <td id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810drow6_col3\" class=\"data row6 col3\">\n",
       "                    0.107588\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810d\" class=\"row_heading level3 row7\">\n",
       "                    7\n",
       "                \n",
       "                <td id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810drow7_col0\" class=\"data row7 col0\">\n",
       "                    0.251497\n",
       "                \n",
       "                <td id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810drow7_col1\" class=\"data row7 col1\">\n",
       "                    -2.65956\n",
       "                \n",
       "                <td id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810drow7_col2\" class=\"data row7 col2\">\n",
       "                    0.803005\n",
       "                \n",
       "                <td id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810drow7_col3\" class=\"data row7 col3\">\n",
       "                    -0.0121781\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810d\" class=\"row_heading level3 row8\">\n",
       "                    8\n",
       "                \n",
       "                <td id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810drow8_col0\" class=\"data row8 col0\">\n",
       "                    1.96226\n",
       "                \n",
       "                <td id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810drow8_col1\" class=\"data row8 col1\">\n",
       "                    -1.22001\n",
       "                \n",
       "                <td id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810drow8_col2\" class=\"data row8 col2\">\n",
       "                    -1.02514\n",
       "                \n",
       "                <td id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810drow8_col3\" class=\"data row8 col3\">\n",
       "                    -0.922657\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810d\" class=\"row_heading level3 row9\">\n",
       "                    9\n",
       "                \n",
       "                <td id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810drow9_col0\" class=\"data row9 col0\">\n",
       "                    0.706176\n",
       "                \n",
       "                <td id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810drow9_col1\" class=\"data row9 col1\">\n",
       "                    -1.28399\n",
       "                \n",
       "                <td id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810drow9_col2\" class=\"data row9 col2\">\n",
       "                    0.323935\n",
       "                \n",
       "                <td id=\"T_01e5429a_f2f9_11e7_bfc9_240a64de810drow9_col3\" class=\"data row9 col3\">\n",
       "                    -1.03275\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "        </tbody>\n",
       "        </table>\n",
       "        "
      ],
      "text/plain": [
       "<pandas.formats.style.Styler at 0x4995a90>"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 样式索引、切片\n",
    "\n",
    "df.style.apply(highlight_max, axis = 1, \n",
    "               subset = pd.IndexSlice[2:5,['b', 'd']])\n",
    "# 通过pd.IndexSlice[]调用切片\n",
    "# 也可：df[2:5].style.apply(highlight_max, subset = ['b', 'd']) → 先索引行再做样式"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "'''\n",
    "【课程3.14】  表格显示控制\n",
    "\n",
    "df.style.format()\n",
    " \n",
    "'''"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "          a         b         c         d\n",
      "0 -1.458644 -0.655620  0.134962  0.487259\n",
      "1  0.921098  0.631805  0.943667 -0.669659\n",
      "2  1.162486 -1.362738  0.015851  0.720793\n",
      "3  1.250515  2.166381  0.222424  1.696663\n",
      "4 -0.655765 -0.768403 -1.802734  0.087619\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "\n",
       "        <style  type=\"text/css\" >\n",
       "        \n",
       "        \n",
       "        </style>\n",
       "\n",
       "        <table id=\"T_02a7f934_f2f9_11e7_8581_240a64de810d\" None>\n",
       "        \n",
       "\n",
       "        <thead>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th class=\"blank\">\n",
       "                \n",
       "                <th class=\"col_heading level0 col0\">a\n",
       "                \n",
       "                <th class=\"col_heading level0 col1\">b\n",
       "                \n",
       "                <th class=\"col_heading level0 col2\">c\n",
       "                \n",
       "                <th class=\"col_heading level0 col3\">d\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "        </thead>\n",
       "        <tbody>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_02a7f934_f2f9_11e7_8581_240a64de810d\" class=\"row_heading level3 row0\">\n",
       "                    0\n",
       "                \n",
       "                <td id=\"T_02a7f934_f2f9_11e7_8581_240a64de810drow0_col0\" class=\"data row0 col0\">\n",
       "                    -145.86%\n",
       "                \n",
       "                <td id=\"T_02a7f934_f2f9_11e7_8581_240a64de810drow0_col1\" class=\"data row0 col1\">\n",
       "                    -65.56%\n",
       "                \n",
       "                <td id=\"T_02a7f934_f2f9_11e7_8581_240a64de810drow0_col2\" class=\"data row0 col2\">\n",
       "                    13.50%\n",
       "                \n",
       "                <td id=\"T_02a7f934_f2f9_11e7_8581_240a64de810drow0_col3\" class=\"data row0 col3\">\n",
       "                    48.73%\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_02a7f934_f2f9_11e7_8581_240a64de810d\" class=\"row_heading level3 row1\">\n",
       "                    1\n",
       "                \n",
       "                <td id=\"T_02a7f934_f2f9_11e7_8581_240a64de810drow1_col0\" class=\"data row1 col0\">\n",
       "                    92.11%\n",
       "                \n",
       "                <td id=\"T_02a7f934_f2f9_11e7_8581_240a64de810drow1_col1\" class=\"data row1 col1\">\n",
       "                    63.18%\n",
       "                \n",
       "                <td id=\"T_02a7f934_f2f9_11e7_8581_240a64de810drow1_col2\" class=\"data row1 col2\">\n",
       "                    94.37%\n",
       "                \n",
       "                <td id=\"T_02a7f934_f2f9_11e7_8581_240a64de810drow1_col3\" class=\"data row1 col3\">\n",
       "                    -66.97%\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_02a7f934_f2f9_11e7_8581_240a64de810d\" class=\"row_heading level3 row2\">\n",
       "                    2\n",
       "                \n",
       "                <td id=\"T_02a7f934_f2f9_11e7_8581_240a64de810drow2_col0\" class=\"data row2 col0\">\n",
       "                    116.25%\n",
       "                \n",
       "                <td id=\"T_02a7f934_f2f9_11e7_8581_240a64de810drow2_col1\" class=\"data row2 col1\">\n",
       "                    -136.27%\n",
       "                \n",
       "                <td id=\"T_02a7f934_f2f9_11e7_8581_240a64de810drow2_col2\" class=\"data row2 col2\">\n",
       "                    1.59%\n",
       "                \n",
       "                <td id=\"T_02a7f934_f2f9_11e7_8581_240a64de810drow2_col3\" class=\"data row2 col3\">\n",
       "                    72.08%\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_02a7f934_f2f9_11e7_8581_240a64de810d\" class=\"row_heading level3 row3\">\n",
       "                    3\n",
       "                \n",
       "                <td id=\"T_02a7f934_f2f9_11e7_8581_240a64de810drow3_col0\" class=\"data row3 col0\">\n",
       "                    125.05%\n",
       "                \n",
       "                <td id=\"T_02a7f934_f2f9_11e7_8581_240a64de810drow3_col1\" class=\"data row3 col1\">\n",
       "                    216.64%\n",
       "                \n",
       "                <td id=\"T_02a7f934_f2f9_11e7_8581_240a64de810drow3_col2\" class=\"data row3 col2\">\n",
       "                    22.24%\n",
       "                \n",
       "                <td id=\"T_02a7f934_f2f9_11e7_8581_240a64de810drow3_col3\" class=\"data row3 col3\">\n",
       "                    169.67%\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_02a7f934_f2f9_11e7_8581_240a64de810d\" class=\"row_heading level3 row4\">\n",
       "                    4\n",
       "                \n",
       "                <td id=\"T_02a7f934_f2f9_11e7_8581_240a64de810drow4_col0\" class=\"data row4 col0\">\n",
       "                    -65.58%\n",
       "                \n",
       "                <td id=\"T_02a7f934_f2f9_11e7_8581_240a64de810drow4_col1\" class=\"data row4 col1\">\n",
       "                    -76.84%\n",
       "                \n",
       "                <td id=\"T_02a7f934_f2f9_11e7_8581_240a64de810drow4_col2\" class=\"data row4 col2\">\n",
       "                    -180.27%\n",
       "                \n",
       "                <td id=\"T_02a7f934_f2f9_11e7_8581_240a64de810drow4_col3\" class=\"data row4 col3\">\n",
       "                    8.76%\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "        </tbody>\n",
       "        </table>\n",
       "        "
      ],
      "text/plain": [
       "<pandas.formats.style.Styler at 0x98787b8>"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 按照百分数显示\n",
    "\n",
    "df = pd.DataFrame(np.random.randn(10,4),columns=['a','b','c','d'])\n",
    "print(df.head())\n",
    "df.head().style.format(\"{:.2%}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "        <style  type=\"text/css\" >\n",
       "        \n",
       "        \n",
       "        </style>\n",
       "\n",
       "        <table id=\"T_03b7233a_f2f9_11e7_9343_240a64de810d\" None>\n",
       "        \n",
       "\n",
       "        <thead>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th class=\"blank\">\n",
       "                \n",
       "                <th class=\"col_heading level0 col0\">a\n",
       "                \n",
       "                <th class=\"col_heading level0 col1\">b\n",
       "                \n",
       "                <th class=\"col_heading level0 col2\">c\n",
       "                \n",
       "                <th class=\"col_heading level0 col3\">d\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "        </thead>\n",
       "        <tbody>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_03b7233a_f2f9_11e7_9343_240a64de810d\" class=\"row_heading level3 row0\">\n",
       "                    0\n",
       "                \n",
       "                <td id=\"T_03b7233a_f2f9_11e7_9343_240a64de810drow0_col0\" class=\"data row0 col0\">\n",
       "                    -1.4586\n",
       "                \n",
       "                <td id=\"T_03b7233a_f2f9_11e7_9343_240a64de810drow0_col1\" class=\"data row0 col1\">\n",
       "                    -0.6556\n",
       "                \n",
       "                <td id=\"T_03b7233a_f2f9_11e7_9343_240a64de810drow0_col2\" class=\"data row0 col2\">\n",
       "                    0.1350\n",
       "                \n",
       "                <td id=\"T_03b7233a_f2f9_11e7_9343_240a64de810drow0_col3\" class=\"data row0 col3\">\n",
       "                    0.4873\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_03b7233a_f2f9_11e7_9343_240a64de810d\" class=\"row_heading level3 row1\">\n",
       "                    1\n",
       "                \n",
       "                <td id=\"T_03b7233a_f2f9_11e7_9343_240a64de810drow1_col0\" class=\"data row1 col0\">\n",
       "                    0.9211\n",
       "                \n",
       "                <td id=\"T_03b7233a_f2f9_11e7_9343_240a64de810drow1_col1\" class=\"data row1 col1\">\n",
       "                    0.6318\n",
       "                \n",
       "                <td id=\"T_03b7233a_f2f9_11e7_9343_240a64de810drow1_col2\" class=\"data row1 col2\">\n",
       "                    0.9437\n",
       "                \n",
       "                <td id=\"T_03b7233a_f2f9_11e7_9343_240a64de810drow1_col3\" class=\"data row1 col3\">\n",
       "                    -0.6697\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_03b7233a_f2f9_11e7_9343_240a64de810d\" class=\"row_heading level3 row2\">\n",
       "                    2\n",
       "                \n",
       "                <td id=\"T_03b7233a_f2f9_11e7_9343_240a64de810drow2_col0\" class=\"data row2 col0\">\n",
       "                    1.1625\n",
       "                \n",
       "                <td id=\"T_03b7233a_f2f9_11e7_9343_240a64de810drow2_col1\" class=\"data row2 col1\">\n",
       "                    -1.3627\n",
       "                \n",
       "                <td id=\"T_03b7233a_f2f9_11e7_9343_240a64de810drow2_col2\" class=\"data row2 col2\">\n",
       "                    0.0159\n",
       "                \n",
       "                <td id=\"T_03b7233a_f2f9_11e7_9343_240a64de810drow2_col3\" class=\"data row2 col3\">\n",
       "                    0.7208\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_03b7233a_f2f9_11e7_9343_240a64de810d\" class=\"row_heading level3 row3\">\n",
       "                    3\n",
       "                \n",
       "                <td id=\"T_03b7233a_f2f9_11e7_9343_240a64de810drow3_col0\" class=\"data row3 col0\">\n",
       "                    1.2505\n",
       "                \n",
       "                <td id=\"T_03b7233a_f2f9_11e7_9343_240a64de810drow3_col1\" class=\"data row3 col1\">\n",
       "                    2.1664\n",
       "                \n",
       "                <td id=\"T_03b7233a_f2f9_11e7_9343_240a64de810drow3_col2\" class=\"data row3 col2\">\n",
       "                    0.2224\n",
       "                \n",
       "                <td id=\"T_03b7233a_f2f9_11e7_9343_240a64de810drow3_col3\" class=\"data row3 col3\">\n",
       "                    1.6967\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_03b7233a_f2f9_11e7_9343_240a64de810d\" class=\"row_heading level3 row4\">\n",
       "                    4\n",
       "                \n",
       "                <td id=\"T_03b7233a_f2f9_11e7_9343_240a64de810drow4_col0\" class=\"data row4 col0\">\n",
       "                    -0.6558\n",
       "                \n",
       "                <td id=\"T_03b7233a_f2f9_11e7_9343_240a64de810drow4_col1\" class=\"data row4 col1\">\n",
       "                    -0.7684\n",
       "                \n",
       "                <td id=\"T_03b7233a_f2f9_11e7_9343_240a64de810drow4_col2\" class=\"data row4 col2\">\n",
       "                    -1.8027\n",
       "                \n",
       "                <td id=\"T_03b7233a_f2f9_11e7_9343_240a64de810drow4_col3\" class=\"data row4 col3\">\n",
       "                    0.0876\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "        </tbody>\n",
       "        </table>\n",
       "        "
      ],
      "text/plain": [
       "<pandas.formats.style.Styler at 0x4995cf8>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 显示小数点数\n",
    "\n",
    "df.head().style.format(\"{:.4f}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "        <style  type=\"text/css\" >\n",
       "        \n",
       "        \n",
       "        </style>\n",
       "\n",
       "        <table id=\"T_04642ea4_f2f9_11e7_b387_240a64de810d\" None>\n",
       "        \n",
       "\n",
       "        <thead>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th class=\"blank\">\n",
       "                \n",
       "                <th class=\"col_heading level0 col0\">a\n",
       "                \n",
       "                <th class=\"col_heading level0 col1\">b\n",
       "                \n",
       "                <th class=\"col_heading level0 col2\">c\n",
       "                \n",
       "                <th class=\"col_heading level0 col3\">d\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "        </thead>\n",
       "        <tbody>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_04642ea4_f2f9_11e7_b387_240a64de810d\" class=\"row_heading level3 row0\">\n",
       "                    0\n",
       "                \n",
       "                <td id=\"T_04642ea4_f2f9_11e7_b387_240a64de810drow0_col0\" class=\"data row0 col0\">\n",
       "                    -1.46\n",
       "                \n",
       "                <td id=\"T_04642ea4_f2f9_11e7_b387_240a64de810drow0_col1\" class=\"data row0 col1\">\n",
       "                    -0.66\n",
       "                \n",
       "                <td id=\"T_04642ea4_f2f9_11e7_b387_240a64de810drow0_col2\" class=\"data row0 col2\">\n",
       "                    +0.13\n",
       "                \n",
       "                <td id=\"T_04642ea4_f2f9_11e7_b387_240a64de810drow0_col3\" class=\"data row0 col3\">\n",
       "                    +0.49\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_04642ea4_f2f9_11e7_b387_240a64de810d\" class=\"row_heading level3 row1\">\n",
       "                    1\n",
       "                \n",
       "                <td id=\"T_04642ea4_f2f9_11e7_b387_240a64de810drow1_col0\" class=\"data row1 col0\">\n",
       "                    +0.92\n",
       "                \n",
       "                <td id=\"T_04642ea4_f2f9_11e7_b387_240a64de810drow1_col1\" class=\"data row1 col1\">\n",
       "                    +0.63\n",
       "                \n",
       "                <td id=\"T_04642ea4_f2f9_11e7_b387_240a64de810drow1_col2\" class=\"data row1 col2\">\n",
       "                    +0.94\n",
       "                \n",
       "                <td id=\"T_04642ea4_f2f9_11e7_b387_240a64de810drow1_col3\" class=\"data row1 col3\">\n",
       "                    -0.67\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_04642ea4_f2f9_11e7_b387_240a64de810d\" class=\"row_heading level3 row2\">\n",
       "                    2\n",
       "                \n",
       "                <td id=\"T_04642ea4_f2f9_11e7_b387_240a64de810drow2_col0\" class=\"data row2 col0\">\n",
       "                    +1.16\n",
       "                \n",
       "                <td id=\"T_04642ea4_f2f9_11e7_b387_240a64de810drow2_col1\" class=\"data row2 col1\">\n",
       "                    -1.36\n",
       "                \n",
       "                <td id=\"T_04642ea4_f2f9_11e7_b387_240a64de810drow2_col2\" class=\"data row2 col2\">\n",
       "                    +0.02\n",
       "                \n",
       "                <td id=\"T_04642ea4_f2f9_11e7_b387_240a64de810drow2_col3\" class=\"data row2 col3\">\n",
       "                    +0.72\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_04642ea4_f2f9_11e7_b387_240a64de810d\" class=\"row_heading level3 row3\">\n",
       "                    3\n",
       "                \n",
       "                <td id=\"T_04642ea4_f2f9_11e7_b387_240a64de810drow3_col0\" class=\"data row3 col0\">\n",
       "                    +1.25\n",
       "                \n",
       "                <td id=\"T_04642ea4_f2f9_11e7_b387_240a64de810drow3_col1\" class=\"data row3 col1\">\n",
       "                    +2.17\n",
       "                \n",
       "                <td id=\"T_04642ea4_f2f9_11e7_b387_240a64de810drow3_col2\" class=\"data row3 col2\">\n",
       "                    +0.22\n",
       "                \n",
       "                <td id=\"T_04642ea4_f2f9_11e7_b387_240a64de810drow3_col3\" class=\"data row3 col3\">\n",
       "                    +1.70\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_04642ea4_f2f9_11e7_b387_240a64de810d\" class=\"row_heading level3 row4\">\n",
       "                    4\n",
       "                \n",
       "                <td id=\"T_04642ea4_f2f9_11e7_b387_240a64de810drow4_col0\" class=\"data row4 col0\">\n",
       "                    -0.66\n",
       "                \n",
       "                <td id=\"T_04642ea4_f2f9_11e7_b387_240a64de810drow4_col1\" class=\"data row4 col1\">\n",
       "                    -0.77\n",
       "                \n",
       "                <td id=\"T_04642ea4_f2f9_11e7_b387_240a64de810drow4_col2\" class=\"data row4 col2\">\n",
       "                    -1.80\n",
       "                \n",
       "                <td id=\"T_04642ea4_f2f9_11e7_b387_240a64de810drow4_col3\" class=\"data row4 col3\">\n",
       "                    +0.09\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "        </tbody>\n",
       "        </table>\n",
       "        "
      ],
      "text/plain": [
       "<pandas.formats.style.Styler at 0x4995eb8>"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 显示正负数\n",
    "\n",
    "df.head().style.format(\"{:+.2f}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "        <style  type=\"text/css\" >\n",
       "        \n",
       "        \n",
       "        </style>\n",
       "\n",
       "        <table id=\"T_053c906e_f2f9_11e7_b49d_240a64de810d\" None>\n",
       "        \n",
       "\n",
       "        <thead>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th class=\"blank\">\n",
       "                \n",
       "                <th class=\"col_heading level0 col0\">a\n",
       "                \n",
       "                <th class=\"col_heading level0 col1\">b\n",
       "                \n",
       "                <th class=\"col_heading level0 col2\">c\n",
       "                \n",
       "                <th class=\"col_heading level0 col3\">d\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "        </thead>\n",
       "        <tbody>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_053c906e_f2f9_11e7_b49d_240a64de810d\" class=\"row_heading level3 row0\">\n",
       "                    0\n",
       "                \n",
       "                <td id=\"T_053c906e_f2f9_11e7_b49d_240a64de810drow0_col0\" class=\"data row0 col0\">\n",
       "                    -1.45864\n",
       "                \n",
       "                <td id=\"T_053c906e_f2f9_11e7_b49d_240a64de810drow0_col1\" class=\"data row0 col1\">\n",
       "                    -65.56%\n",
       "                \n",
       "                <td id=\"T_053c906e_f2f9_11e7_b49d_240a64de810drow0_col2\" class=\"data row0 col2\">\n",
       "                    +0.135\n",
       "                \n",
       "                <td id=\"T_053c906e_f2f9_11e7_b49d_240a64de810drow0_col3\" class=\"data row0 col3\">\n",
       "                    0.487\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_053c906e_f2f9_11e7_b49d_240a64de810d\" class=\"row_heading level3 row1\">\n",
       "                    1\n",
       "                \n",
       "                <td id=\"T_053c906e_f2f9_11e7_b49d_240a64de810drow1_col0\" class=\"data row1 col0\">\n",
       "                    0.921098\n",
       "                \n",
       "                <td id=\"T_053c906e_f2f9_11e7_b49d_240a64de810drow1_col1\" class=\"data row1 col1\">\n",
       "                    63.18%\n",
       "                \n",
       "                <td id=\"T_053c906e_f2f9_11e7_b49d_240a64de810drow1_col2\" class=\"data row1 col2\">\n",
       "                    +0.944\n",
       "                \n",
       "                <td id=\"T_053c906e_f2f9_11e7_b49d_240a64de810drow1_col3\" class=\"data row1 col3\">\n",
       "                    -0.670\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_053c906e_f2f9_11e7_b49d_240a64de810d\" class=\"row_heading level3 row2\">\n",
       "                    2\n",
       "                \n",
       "                <td id=\"T_053c906e_f2f9_11e7_b49d_240a64de810drow2_col0\" class=\"data row2 col0\">\n",
       "                    1.16249\n",
       "                \n",
       "                <td id=\"T_053c906e_f2f9_11e7_b49d_240a64de810drow2_col1\" class=\"data row2 col1\">\n",
       "                    -136.27%\n",
       "                \n",
       "                <td id=\"T_053c906e_f2f9_11e7_b49d_240a64de810drow2_col2\" class=\"data row2 col2\">\n",
       "                    +0.016\n",
       "                \n",
       "                <td id=\"T_053c906e_f2f9_11e7_b49d_240a64de810drow2_col3\" class=\"data row2 col3\">\n",
       "                    0.721\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_053c906e_f2f9_11e7_b49d_240a64de810d\" class=\"row_heading level3 row3\">\n",
       "                    3\n",
       "                \n",
       "                <td id=\"T_053c906e_f2f9_11e7_b49d_240a64de810drow3_col0\" class=\"data row3 col0\">\n",
       "                    1.25052\n",
       "                \n",
       "                <td id=\"T_053c906e_f2f9_11e7_b49d_240a64de810drow3_col1\" class=\"data row3 col1\">\n",
       "                    216.64%\n",
       "                \n",
       "                <td id=\"T_053c906e_f2f9_11e7_b49d_240a64de810drow3_col2\" class=\"data row3 col2\">\n",
       "                    +0.222\n",
       "                \n",
       "                <td id=\"T_053c906e_f2f9_11e7_b49d_240a64de810drow3_col3\" class=\"data row3 col3\">\n",
       "                    1.697\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_053c906e_f2f9_11e7_b49d_240a64de810d\" class=\"row_heading level3 row4\">\n",
       "                    4\n",
       "                \n",
       "                <td id=\"T_053c906e_f2f9_11e7_b49d_240a64de810drow4_col0\" class=\"data row4 col0\">\n",
       "                    -0.655765\n",
       "                \n",
       "                <td id=\"T_053c906e_f2f9_11e7_b49d_240a64de810drow4_col1\" class=\"data row4 col1\">\n",
       "                    -76.84%\n",
       "                \n",
       "                <td id=\"T_053c906e_f2f9_11e7_b49d_240a64de810drow4_col2\" class=\"data row4 col2\">\n",
       "                    -1.803\n",
       "                \n",
       "                <td id=\"T_053c906e_f2f9_11e7_b49d_240a64de810drow4_col3\" class=\"data row4 col3\">\n",
       "                    0.088\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "        </tbody>\n",
       "        </table>\n",
       "        "
      ],
      "text/plain": [
       "<pandas.formats.style.Styler at 0x98780b8>"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 分列显示\n",
    "\n",
    "df.head().style.format({'b':\"{:.2%}\", 'c':\"{:+.3f}\", 'd':\"{:.3f}\"})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "'''\n",
    "【课程3.15】  表格样式调用\n",
    "\n",
    "Styler内置样式调用\n",
    " \n",
    "'''"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "        <style  type=\"text/css\" >\n",
       "        \n",
       "        \n",
       "            #T_0603dafa_f2f9_11e7_b220_240a64de810drow2_col0 {\n",
       "            \n",
       "                background-color:  red;\n",
       "            \n",
       "            }\n",
       "        \n",
       "        </style>\n",
       "\n",
       "        <table id=\"T_0603dafa_f2f9_11e7_b220_240a64de810d\" None>\n",
       "        \n",
       "\n",
       "        <thead>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th class=\"blank\">\n",
       "                \n",
       "                <th class=\"col_heading level0 col0\">A\n",
       "                \n",
       "                <th class=\"col_heading level0 col1\">B\n",
       "                \n",
       "                <th class=\"col_heading level0 col2\">C\n",
       "                \n",
       "                <th class=\"col_heading level0 col3\">D\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "        </thead>\n",
       "        <tbody>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_0603dafa_f2f9_11e7_b220_240a64de810d\" class=\"row_heading level3 row0\">\n",
       "                    0\n",
       "                \n",
       "                <td id=\"T_0603dafa_f2f9_11e7_b220_240a64de810drow0_col0\" class=\"data row0 col0\">\n",
       "                    0.714752\n",
       "                \n",
       "                <td id=\"T_0603dafa_f2f9_11e7_b220_240a64de810drow0_col1\" class=\"data row0 col1\">\n",
       "                    0.244419\n",
       "                \n",
       "                <td id=\"T_0603dafa_f2f9_11e7_b220_240a64de810drow0_col2\" class=\"data row0 col2\">\n",
       "                    0.757845\n",
       "                \n",
       "                <td id=\"T_0603dafa_f2f9_11e7_b220_240a64de810drow0_col3\" class=\"data row0 col3\">\n",
       "                    0.166515\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_0603dafa_f2f9_11e7_b220_240a64de810d\" class=\"row_heading level3 row1\">\n",
       "                    1\n",
       "                \n",
       "                <td id=\"T_0603dafa_f2f9_11e7_b220_240a64de810drow1_col0\" class=\"data row1 col0\">\n",
       "                    0.299022\n",
       "                \n",
       "                <td id=\"T_0603dafa_f2f9_11e7_b220_240a64de810drow1_col1\" class=\"data row1 col1\">\n",
       "                    0.669106\n",
       "                \n",
       "                <td id=\"T_0603dafa_f2f9_11e7_b220_240a64de810drow1_col2\" class=\"data row1 col2\">\n",
       "                    0.866447\n",
       "                \n",
       "                <td id=\"T_0603dafa_f2f9_11e7_b220_240a64de810drow1_col3\" class=\"data row1 col3\">\n",
       "                    0.798063\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_0603dafa_f2f9_11e7_b220_240a64de810d\" class=\"row_heading level3 row2\">\n",
       "                    2\n",
       "                \n",
       "                <td id=\"T_0603dafa_f2f9_11e7_b220_240a64de810drow2_col0\" class=\"data row2 col0\">\n",
       "                    nan\n",
       "                \n",
       "                <td id=\"T_0603dafa_f2f9_11e7_b220_240a64de810drow2_col1\" class=\"data row2 col1\">\n",
       "                    0.333066\n",
       "                \n",
       "                <td id=\"T_0603dafa_f2f9_11e7_b220_240a64de810drow2_col2\" class=\"data row2 col2\">\n",
       "                    0.552096\n",
       "                \n",
       "                <td id=\"T_0603dafa_f2f9_11e7_b220_240a64de810drow2_col3\" class=\"data row2 col3\">\n",
       "                    0.625966\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_0603dafa_f2f9_11e7_b220_240a64de810d\" class=\"row_heading level3 row3\">\n",
       "                    3\n",
       "                \n",
       "                <td id=\"T_0603dafa_f2f9_11e7_b220_240a64de810drow3_col0\" class=\"data row3 col0\">\n",
       "                    0.745323\n",
       "                \n",
       "                <td id=\"T_0603dafa_f2f9_11e7_b220_240a64de810drow3_col1\" class=\"data row3 col1\">\n",
       "                    0.284294\n",
       "                \n",
       "                <td id=\"T_0603dafa_f2f9_11e7_b220_240a64de810drow3_col2\" class=\"data row3 col2\">\n",
       "                    0.961832\n",
       "                \n",
       "                <td id=\"T_0603dafa_f2f9_11e7_b220_240a64de810drow3_col3\" class=\"data row3 col3\">\n",
       "                    0.84158\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_0603dafa_f2f9_11e7_b220_240a64de810d\" class=\"row_heading level3 row4\">\n",
       "                    4\n",
       "                \n",
       "                <td id=\"T_0603dafa_f2f9_11e7_b220_240a64de810drow4_col0\" class=\"data row4 col0\">\n",
       "                    0.373925\n",
       "                \n",
       "                <td id=\"T_0603dafa_f2f9_11e7_b220_240a64de810drow4_col1\" class=\"data row4 col1\">\n",
       "                    0.314152\n",
       "                \n",
       "                <td id=\"T_0603dafa_f2f9_11e7_b220_240a64de810drow4_col2\" class=\"data row4 col2\">\n",
       "                    0.61255\n",
       "                \n",
       "                <td id=\"T_0603dafa_f2f9_11e7_b220_240a64de810drow4_col3\" class=\"data row4 col3\">\n",
       "                    0.173583\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "        </tbody>\n",
       "        </table>\n",
       "        "
      ],
      "text/plain": [
       "<pandas.formats.style.Styler at 0x98bd358>"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 定位空值\n",
    "\n",
    "df = pd.DataFrame(np.random.rand(5,4),columns = list('ABCD'))\n",
    "df['A'][2] = np.nan\n",
    "df.style.highlight_null(null_color='red')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "        <style  type=\"text/css\" >\n",
       "        \n",
       "        \n",
       "            #T_06c04fee_f2f9_11e7_aba0_240a64de810drow0_col0 {\n",
       "            \n",
       "                background-color:  #e5f5e0;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_06c04fee_f2f9_11e7_aba0_240a64de810drow0_col1 {\n",
       "            \n",
       "                background-color:  #a9dca3;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_06c04fee_f2f9_11e7_aba0_240a64de810drow0_col2 {\n",
       "            \n",
       "                background-color:  #f7fcf5;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_06c04fee_f2f9_11e7_aba0_240a64de810drow0_col3 {\n",
       "            \n",
       "                background-color:  #73c476;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_06c04fee_f2f9_11e7_aba0_240a64de810drow1_col0 {\n",
       "            \n",
       "                background-color:  #8dd08a;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_06c04fee_f2f9_11e7_aba0_240a64de810drow1_col1 {\n",
       "            \n",
       "                background-color:  #d2edcc;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_06c04fee_f2f9_11e7_aba0_240a64de810drow1_col2 {\n",
       "            \n",
       "                background-color:  #73c476;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_06c04fee_f2f9_11e7_aba0_240a64de810drow1_col3 {\n",
       "            \n",
       "                background-color:  #f7fcf5;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_06c04fee_f2f9_11e7_aba0_240a64de810drow2_col0 {\n",
       "            \n",
       "                background-color:  #9bd696;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_06c04fee_f2f9_11e7_aba0_240a64de810drow2_col1 {\n",
       "            \n",
       "                background-color:  #f7fcf5;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_06c04fee_f2f9_11e7_aba0_240a64de810drow2_col2 {\n",
       "            \n",
       "                background-color:  #75c477;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_06c04fee_f2f9_11e7_aba0_240a64de810drow2_col3 {\n",
       "            \n",
       "                background-color:  #90d18d;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_06c04fee_f2f9_11e7_aba0_240a64de810drow3_col0 {\n",
       "            \n",
       "                background-color:  #73c476;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_06c04fee_f2f9_11e7_aba0_240a64de810drow3_col1 {\n",
       "            \n",
       "                background-color:  #f7fcf5;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_06c04fee_f2f9_11e7_aba0_240a64de810drow3_col2 {\n",
       "            \n",
       "                background-color:  #c1e6ba;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_06c04fee_f2f9_11e7_aba0_240a64de810drow3_col3 {\n",
       "            \n",
       "                background-color:  #e7f6e2;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_06c04fee_f2f9_11e7_aba0_240a64de810drow4_col0 {\n",
       "            \n",
       "                background-color:  #73c476;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_06c04fee_f2f9_11e7_aba0_240a64de810drow4_col1 {\n",
       "            \n",
       "                background-color:  #e7f6e2;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_06c04fee_f2f9_11e7_aba0_240a64de810drow4_col2 {\n",
       "            \n",
       "                background-color:  #c0e6b9;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_06c04fee_f2f9_11e7_aba0_240a64de810drow4_col3 {\n",
       "            \n",
       "                background-color:  #f7fcf5;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_06c04fee_f2f9_11e7_aba0_240a64de810drow5_col0 {\n",
       "            \n",
       "                background-color:  #f7fcf5;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_06c04fee_f2f9_11e7_aba0_240a64de810drow5_col1 {\n",
       "            \n",
       "                background-color:  #73c476;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_06c04fee_f2f9_11e7_aba0_240a64de810drow5_col2 {\n",
       "            \n",
       "                background-color:  #f5fbf2;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_06c04fee_f2f9_11e7_aba0_240a64de810drow5_col3 {\n",
       "            \n",
       "                background-color:  #94d390;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_06c04fee_f2f9_11e7_aba0_240a64de810drow6_col0 {\n",
       "            \n",
       "                background-color:  #73c476;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_06c04fee_f2f9_11e7_aba0_240a64de810drow6_col1 {\n",
       "            \n",
       "                background-color:  #a9dca3;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_06c04fee_f2f9_11e7_aba0_240a64de810drow6_col2 {\n",
       "            \n",
       "                background-color:  #c3e7bc;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_06c04fee_f2f9_11e7_aba0_240a64de810drow6_col3 {\n",
       "            \n",
       "                background-color:  #f7fcf5;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_06c04fee_f2f9_11e7_aba0_240a64de810drow7_col0 {\n",
       "            \n",
       "                background-color:  #eff9ec;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_06c04fee_f2f9_11e7_aba0_240a64de810drow7_col1 {\n",
       "            \n",
       "                background-color:  #aedea7;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_06c04fee_f2f9_11e7_aba0_240a64de810drow7_col2 {\n",
       "            \n",
       "                background-color:  #73c476;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_06c04fee_f2f9_11e7_aba0_240a64de810drow7_col3 {\n",
       "            \n",
       "                background-color:  #f7fcf5;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_06c04fee_f2f9_11e7_aba0_240a64de810drow8_col0 {\n",
       "            \n",
       "                background-color:  #f7fcf5;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_06c04fee_f2f9_11e7_aba0_240a64de810drow8_col1 {\n",
       "            \n",
       "                background-color:  #73c476;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_06c04fee_f2f9_11e7_aba0_240a64de810drow8_col2 {\n",
       "            \n",
       "                background-color:  #afdfa8;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_06c04fee_f2f9_11e7_aba0_240a64de810drow8_col3 {\n",
       "            \n",
       "                background-color:  #acdea6;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_06c04fee_f2f9_11e7_aba0_240a64de810drow9_col0 {\n",
       "            \n",
       "                background-color:  #f7fcf5;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_06c04fee_f2f9_11e7_aba0_240a64de810drow9_col1 {\n",
       "            \n",
       "                background-color:  #73c476;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_06c04fee_f2f9_11e7_aba0_240a64de810drow9_col2 {\n",
       "            \n",
       "                background-color:  #eef8ea;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_06c04fee_f2f9_11e7_aba0_240a64de810drow9_col3 {\n",
       "            \n",
       "                background-color:  #e8f6e3;\n",
       "            \n",
       "            }\n",
       "        \n",
       "        </style>\n",
       "\n",
       "        <table id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810d\" None>\n",
       "        \n",
       "\n",
       "        <thead>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th class=\"blank\">\n",
       "                \n",
       "                <th class=\"col_heading level0 col0\">A\n",
       "                \n",
       "                <th class=\"col_heading level0 col1\">B\n",
       "                \n",
       "                <th class=\"col_heading level0 col2\">C\n",
       "                \n",
       "                <th class=\"col_heading level0 col3\">D\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "        </thead>\n",
       "        <tbody>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810d\" class=\"row_heading level3 row0\">\n",
       "                    0\n",
       "                \n",
       "                <td id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810drow0_col0\" class=\"data row0 col0\">\n",
       "                    0.35589\n",
       "                \n",
       "                <td id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810drow0_col1\" class=\"data row0 col1\">\n",
       "                    0.705106\n",
       "                \n",
       "                <td id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810drow0_col2\" class=\"data row0 col2\">\n",
       "                    0.156272\n",
       "                \n",
       "                <td id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810drow0_col3\" class=\"data row0 col3\">\n",
       "                    0.94045\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810d\" class=\"row_heading level3 row1\">\n",
       "                    1\n",
       "                \n",
       "                <td id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810drow1_col0\" class=\"data row1 col0\">\n",
       "                    0.782459\n",
       "                \n",
       "                <td id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810drow1_col1\" class=\"data row1 col1\">\n",
       "                    0.475351\n",
       "                \n",
       "                <td id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810drow1_col2\" class=\"data row1 col2\">\n",
       "                    0.874163\n",
       "                \n",
       "                <td id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810drow1_col3\" class=\"data row1 col3\">\n",
       "                    0.198793\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810d\" class=\"row_heading level3 row2\">\n",
       "                    2\n",
       "                \n",
       "                <td id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810drow2_col0\" class=\"data row2 col0\">\n",
       "                    0.678382\n",
       "                \n",
       "                <td id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810drow2_col1\" class=\"data row2 col1\">\n",
       "                    0.0927048\n",
       "                \n",
       "                <td id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810drow2_col2\" class=\"data row2 col2\">\n",
       "                    0.83857\n",
       "                \n",
       "                <td id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810drow2_col3\" class=\"data row2 col3\">\n",
       "                    0.723829\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810d\" class=\"row_heading level3 row3\">\n",
       "                    3\n",
       "                \n",
       "                <td id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810drow3_col0\" class=\"data row3 col0\">\n",
       "                    0.686543\n",
       "                \n",
       "                <td id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810drow3_col1\" class=\"data row3 col1\">\n",
       "                    0.210492\n",
       "                \n",
       "                <td id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810drow3_col2\" class=\"data row3 col2\">\n",
       "                    0.467397\n",
       "                \n",
       "                <td id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810drow3_col3\" class=\"data row3 col3\">\n",
       "                    0.321684\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810d\" class=\"row_heading level3 row4\">\n",
       "                    4\n",
       "                \n",
       "                <td id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810drow4_col0\" class=\"data row4 col0\">\n",
       "                    0.920856\n",
       "                \n",
       "                <td id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810drow4_col1\" class=\"data row4 col1\">\n",
       "                    0.507327\n",
       "                \n",
       "                <td id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810drow4_col2\" class=\"data row4 col2\">\n",
       "                    0.678301\n",
       "                \n",
       "                <td id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810drow4_col3\" class=\"data row4 col3\">\n",
       "                    0.383717\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810d\" class=\"row_heading level3 row5\">\n",
       "                    5\n",
       "                \n",
       "                <td id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810drow5_col0\" class=\"data row5 col0\">\n",
       "                    0.138504\n",
       "                \n",
       "                <td id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810drow5_col1\" class=\"data row5 col1\">\n",
       "                    0.784922\n",
       "                \n",
       "                <td id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810drow5_col2\" class=\"data row5 col2\">\n",
       "                    0.16161\n",
       "                \n",
       "                <td id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810drow5_col3\" class=\"data row5 col3\">\n",
       "                    0.670962\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810d\" class=\"row_heading level3 row6\">\n",
       "                    6\n",
       "                \n",
       "                <td id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810drow6_col0\" class=\"data row6 col0\">\n",
       "                    0.999699\n",
       "                \n",
       "                <td id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810drow6_col1\" class=\"data row6 col1\">\n",
       "                    0.808968\n",
       "                \n",
       "                <td id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810drow6_col2\" class=\"data row6 col2\">\n",
       "                    0.700415\n",
       "                \n",
       "                <td id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810drow6_col3\" class=\"data row6 col3\">\n",
       "                    0.366371\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810d\" class=\"row_heading level3 row7\">\n",
       "                    7\n",
       "                \n",
       "                <td id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810drow7_col0\" class=\"data row7 col0\">\n",
       "                    0.116142\n",
       "                \n",
       "                <td id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810drow7_col1\" class=\"data row7 col1\">\n",
       "                    0.568436\n",
       "                \n",
       "                <td id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810drow7_col2\" class=\"data row7 col2\">\n",
       "                    0.842027\n",
       "                \n",
       "                <td id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810drow7_col3\" class=\"data row7 col3\">\n",
       "                    0.0226978\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810d\" class=\"row_heading level3 row8\">\n",
       "                    8\n",
       "                \n",
       "                <td id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810drow8_col0\" class=\"data row8 col0\">\n",
       "                    0.0213556\n",
       "                \n",
       "                <td id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810drow8_col1\" class=\"data row8 col1\">\n",
       "                    0.865117\n",
       "                \n",
       "                <td id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810drow8_col2\" class=\"data row8 col2\">\n",
       "                    0.57514\n",
       "                \n",
       "                <td id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810drow8_col3\" class=\"data row8 col3\">\n",
       "                    0.592521\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810d\" class=\"row_heading level3 row9\">\n",
       "                    9\n",
       "                \n",
       "                <td id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810drow9_col0\" class=\"data row9 col0\">\n",
       "                    0.0454253\n",
       "                \n",
       "                <td id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810drow9_col1\" class=\"data row9 col1\">\n",
       "                    0.884987\n",
       "                \n",
       "                <td id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810drow9_col2\" class=\"data row9 col2\">\n",
       "                    0.154658\n",
       "                \n",
       "                <td id=\"T_06c04fee_f2f9_11e7_aba0_240a64de810drow9_col3\" class=\"data row9 col3\">\n",
       "                    0.227973\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "        </tbody>\n",
       "        </table>\n",
       "        "
      ],
      "text/plain": [
       "<pandas.formats.style.Styler at 0x9878a90>"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 色彩映射\n",
    "\n",
    "df = pd.DataFrame(np.random.rand(10,4),columns = list('ABCD'))\n",
    "df.style.background_gradient(cmap='Greens',axis =1,low=0,high=1)\n",
    "# cmap：颜色\n",
    "# axis：映射参考，0为行，1以列"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "        <style  type=\"text/css\" >\n",
       "        \n",
       "        \n",
       "            #T_077c76be_f2f9_11e7_9818_240a64de810drow0_col0 {\n",
       "            \n",
       "                width:  10em;\n",
       "            \n",
       "                 height:  80%;\n",
       "            \n",
       "                background:  linear-gradient(90deg,#d65f5f 31.133706771146144%, transparent 0%);\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_077c76be_f2f9_11e7_9818_240a64de810drow0_col1 {\n",
       "            \n",
       "                width:  10em;\n",
       "            \n",
       "                 height:  80%;\n",
       "            \n",
       "                background:  linear-gradient(90deg,#d65f5f 100.0%, transparent 0%);\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_077c76be_f2f9_11e7_9818_240a64de810drow1_col0 {\n",
       "            \n",
       "                width:  10em;\n",
       "            \n",
       "                 height:  80%;\n",
       "            \n",
       "                background:  linear-gradient(90deg,#d65f5f 94.5026674204524%, transparent 0%);\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_077c76be_f2f9_11e7_9818_240a64de810drow1_col1 {\n",
       "            \n",
       "                width:  10em;\n",
       "            \n",
       "                 height:  80%;\n",
       "            \n",
       "                background:  linear-gradient(90deg,#d65f5f 68.94723774983602%, transparent 0%);\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_077c76be_f2f9_11e7_9818_240a64de810drow2_col0 {\n",
       "            \n",
       "                width:  10em;\n",
       "            \n",
       "                 height:  80%;\n",
       "            \n",
       "                background:  linear-gradient(90deg,#d65f5f 99.99999999999999%, transparent 0%);\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_077c76be_f2f9_11e7_9818_240a64de810drow2_col1 {\n",
       "            \n",
       "                width:  10em;\n",
       "            \n",
       "                 height:  80%;\n",
       "            \n",
       "                background:  linear-gradient(90deg,#d65f5f 83.10037919419648%, transparent 0%);\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_077c76be_f2f9_11e7_9818_240a64de810drow3_col0 {\n",
       "            \n",
       "                width:  10em;\n",
       "            \n",
       "                 height:  80%;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_077c76be_f2f9_11e7_9818_240a64de810drow3_col1 {\n",
       "            \n",
       "                width:  10em;\n",
       "            \n",
       "                 height:  80%;\n",
       "            \n",
       "                background:  linear-gradient(90deg,#d65f5f 75.27604676187504%, transparent 0%);\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_077c76be_f2f9_11e7_9818_240a64de810drow4_col0 {\n",
       "            \n",
       "                width:  10em;\n",
       "            \n",
       "                 height:  80%;\n",
       "            \n",
       "                background:  linear-gradient(90deg,#d65f5f 88.36565326972516%, transparent 0%);\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_077c76be_f2f9_11e7_9818_240a64de810drow4_col1 {\n",
       "            \n",
       "                width:  10em;\n",
       "            \n",
       "                 height:  80%;\n",
       "            \n",
       "                background:  linear-gradient(90deg,#d65f5f 67.81286959276436%, transparent 0%);\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_077c76be_f2f9_11e7_9818_240a64de810drow5_col0 {\n",
       "            \n",
       "                width:  10em;\n",
       "            \n",
       "                 height:  80%;\n",
       "            \n",
       "                background:  linear-gradient(90deg,#d65f5f 81.62965518202888%, transparent 0%);\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_077c76be_f2f9_11e7_9818_240a64de810drow5_col1 {\n",
       "            \n",
       "                width:  10em;\n",
       "            \n",
       "                 height:  80%;\n",
       "            \n",
       "                background:  linear-gradient(90deg,#d65f5f 33.37909161873769%, transparent 0%);\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_077c76be_f2f9_11e7_9818_240a64de810drow6_col0 {\n",
       "            \n",
       "                width:  10em;\n",
       "            \n",
       "                 height:  80%;\n",
       "            \n",
       "                background:  linear-gradient(90deg,#d65f5f 32.933658596540035%, transparent 0%);\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_077c76be_f2f9_11e7_9818_240a64de810drow6_col1 {\n",
       "            \n",
       "                width:  10em;\n",
       "            \n",
       "                 height:  80%;\n",
       "            \n",
       "                background:  linear-gradient(90deg,#d65f5f 20.098325885802932%, transparent 0%);\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_077c76be_f2f9_11e7_9818_240a64de810drow7_col0 {\n",
       "            \n",
       "                width:  10em;\n",
       "            \n",
       "                 height:  80%;\n",
       "            \n",
       "                background:  linear-gradient(90deg,#d65f5f 75.7679924265326%, transparent 0%);\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_077c76be_f2f9_11e7_9818_240a64de810drow7_col1 {\n",
       "            \n",
       "                width:  10em;\n",
       "            \n",
       "                 height:  80%;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_077c76be_f2f9_11e7_9818_240a64de810drow8_col0 {\n",
       "            \n",
       "                width:  10em;\n",
       "            \n",
       "                 height:  80%;\n",
       "            \n",
       "                background:  linear-gradient(90deg,#d65f5f 50.75230928415844%, transparent 0%);\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_077c76be_f2f9_11e7_9818_240a64de810drow8_col1 {\n",
       "            \n",
       "                width:  10em;\n",
       "            \n",
       "                 height:  80%;\n",
       "            \n",
       "                background:  linear-gradient(90deg,#d65f5f 75.78536160751887%, transparent 0%);\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_077c76be_f2f9_11e7_9818_240a64de810drow9_col0 {\n",
       "            \n",
       "                width:  10em;\n",
       "            \n",
       "                 height:  80%;\n",
       "            \n",
       "                background:  linear-gradient(90deg,#d65f5f 66.54120707047383%, transparent 0%);\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_077c76be_f2f9_11e7_9818_240a64de810drow9_col1 {\n",
       "            \n",
       "                width:  10em;\n",
       "            \n",
       "                 height:  80%;\n",
       "            \n",
       "                background:  linear-gradient(90deg,#d65f5f 75.71107245148563%, transparent 0%);\n",
       "            \n",
       "            }\n",
       "        \n",
       "        </style>\n",
       "\n",
       "        <table id=\"T_077c76be_f2f9_11e7_9818_240a64de810d\" None>\n",
       "        \n",
       "\n",
       "        <thead>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th class=\"blank\">\n",
       "                \n",
       "                <th class=\"col_heading level0 col0\">A\n",
       "                \n",
       "                <th class=\"col_heading level0 col1\">B\n",
       "                \n",
       "                <th class=\"col_heading level0 col2\">C\n",
       "                \n",
       "                <th class=\"col_heading level0 col3\">D\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "        </thead>\n",
       "        <tbody>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_077c76be_f2f9_11e7_9818_240a64de810d\" class=\"row_heading level3 row0\">\n",
       "                    0\n",
       "                \n",
       "                <td id=\"T_077c76be_f2f9_11e7_9818_240a64de810drow0_col0\" class=\"data row0 col0\">\n",
       "                    0.432267\n",
       "                \n",
       "                <td id=\"T_077c76be_f2f9_11e7_9818_240a64de810drow0_col1\" class=\"data row0 col1\">\n",
       "                    0.92718\n",
       "                \n",
       "                <td id=\"T_077c76be_f2f9_11e7_9818_240a64de810drow0_col2\" class=\"data row0 col2\">\n",
       "                    0.28735\n",
       "                \n",
       "                <td id=\"T_077c76be_f2f9_11e7_9818_240a64de810drow0_col3\" class=\"data row0 col3\">\n",
       "                    0.641502\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_077c76be_f2f9_11e7_9818_240a64de810d\" class=\"row_heading level3 row1\">\n",
       "                    1\n",
       "                \n",
       "                <td id=\"T_077c76be_f2f9_11e7_9818_240a64de810drow1_col0\" class=\"data row1 col0\">\n",
       "                    0.839107\n",
       "                \n",
       "                <td id=\"T_077c76be_f2f9_11e7_9818_240a64de810drow1_col1\" class=\"data row1 col1\">\n",
       "                    0.672681\n",
       "                \n",
       "                <td id=\"T_077c76be_f2f9_11e7_9818_240a64de810drow1_col2\" class=\"data row1 col2\">\n",
       "                    0.0782057\n",
       "                \n",
       "                <td id=\"T_077c76be_f2f9_11e7_9818_240a64de810drow1_col3\" class=\"data row1 col3\">\n",
       "                    0.247411\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_077c76be_f2f9_11e7_9818_240a64de810d\" class=\"row_heading level3 row2\">\n",
       "                    2\n",
       "                \n",
       "                <td id=\"T_077c76be_f2f9_11e7_9818_240a64de810drow2_col0\" class=\"data row2 col0\">\n",
       "                    0.874401\n",
       "                \n",
       "                <td id=\"T_077c76be_f2f9_11e7_9818_240a64de810drow2_col1\" class=\"data row2 col1\">\n",
       "                    0.788676\n",
       "                \n",
       "                <td id=\"T_077c76be_f2f9_11e7_9818_240a64de810drow2_col2\" class=\"data row2 col2\">\n",
       "                    0.496212\n",
       "                \n",
       "                <td id=\"T_077c76be_f2f9_11e7_9818_240a64de810drow2_col3\" class=\"data row2 col3\">\n",
       "                    0.253429\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_077c76be_f2f9_11e7_9818_240a64de810d\" class=\"row_heading level3 row3\">\n",
       "                    3\n",
       "                \n",
       "                <td id=\"T_077c76be_f2f9_11e7_9818_240a64de810drow3_col0\" class=\"data row3 col0\">\n",
       "                    0.232383\n",
       "                \n",
       "                <td id=\"T_077c76be_f2f9_11e7_9818_240a64de810drow3_col1\" class=\"data row3 col1\">\n",
       "                    0.72455\n",
       "                \n",
       "                <td id=\"T_077c76be_f2f9_11e7_9818_240a64de810drow3_col2\" class=\"data row3 col2\">\n",
       "                    0.75625\n",
       "                \n",
       "                <td id=\"T_077c76be_f2f9_11e7_9818_240a64de810drow3_col3\" class=\"data row3 col3\">\n",
       "                    0.230091\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_077c76be_f2f9_11e7_9818_240a64de810d\" class=\"row_heading level3 row4\">\n",
       "                    4\n",
       "                \n",
       "                <td id=\"T_077c76be_f2f9_11e7_9818_240a64de810drow4_col0\" class=\"data row4 col0\">\n",
       "                    0.799707\n",
       "                \n",
       "                <td id=\"T_077c76be_f2f9_11e7_9818_240a64de810drow4_col1\" class=\"data row4 col1\">\n",
       "                    0.663384\n",
       "                \n",
       "                <td id=\"T_077c76be_f2f9_11e7_9818_240a64de810drow4_col2\" class=\"data row4 col2\">\n",
       "                    0.351766\n",
       "                \n",
       "                <td id=\"T_077c76be_f2f9_11e7_9818_240a64de810drow4_col3\" class=\"data row4 col3\">\n",
       "                    0.425221\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_077c76be_f2f9_11e7_9818_240a64de810d\" class=\"row_heading level3 row5\">\n",
       "                    5\n",
       "                \n",
       "                <td id=\"T_077c76be_f2f9_11e7_9818_240a64de810drow5_col0\" class=\"data row5 col0\">\n",
       "                    0.75646\n",
       "                \n",
       "                <td id=\"T_077c76be_f2f9_11e7_9818_240a64de810drow5_col1\" class=\"data row5 col1\">\n",
       "                    0.381174\n",
       "                \n",
       "                <td id=\"T_077c76be_f2f9_11e7_9818_240a64de810drow5_col2\" class=\"data row5 col2\">\n",
       "                    0.922843\n",
       "                \n",
       "                <td id=\"T_077c76be_f2f9_11e7_9818_240a64de810drow5_col3\" class=\"data row5 col3\">\n",
       "                    0.0317737\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_077c76be_f2f9_11e7_9818_240a64de810d\" class=\"row_heading level3 row6\">\n",
       "                    6\n",
       "                \n",
       "                <td id=\"T_077c76be_f2f9_11e7_9818_240a64de810drow6_col0\" class=\"data row6 col0\">\n",
       "                    0.443823\n",
       "                \n",
       "                <td id=\"T_077c76be_f2f9_11e7_9818_240a64de810drow6_col1\" class=\"data row6 col1\">\n",
       "                    0.272329\n",
       "                \n",
       "                <td id=\"T_077c76be_f2f9_11e7_9818_240a64de810drow6_col2\" class=\"data row6 col2\">\n",
       "                    0.102859\n",
       "                \n",
       "                <td id=\"T_077c76be_f2f9_11e7_9818_240a64de810drow6_col3\" class=\"data row6 col3\">\n",
       "                    0.214509\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_077c76be_f2f9_11e7_9818_240a64de810d\" class=\"row_heading level3 row7\">\n",
       "                    7\n",
       "                \n",
       "                <td id=\"T_077c76be_f2f9_11e7_9818_240a64de810drow7_col0\" class=\"data row7 col0\">\n",
       "                    0.718827\n",
       "                \n",
       "                <td id=\"T_077c76be_f2f9_11e7_9818_240a64de810drow7_col1\" class=\"data row7 col1\">\n",
       "                    0.107608\n",
       "                \n",
       "                <td id=\"T_077c76be_f2f9_11e7_9818_240a64de810drow7_col2\" class=\"data row7 col2\">\n",
       "                    0.285968\n",
       "                \n",
       "                <td id=\"T_077c76be_f2f9_11e7_9818_240a64de810drow7_col3\" class=\"data row7 col3\">\n",
       "                    0.0385898\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_077c76be_f2f9_11e7_9818_240a64de810d\" class=\"row_heading level3 row8\">\n",
       "                    8\n",
       "                \n",
       "                <td id=\"T_077c76be_f2f9_11e7_9818_240a64de810drow8_col0\" class=\"data row8 col0\">\n",
       "                    0.558222\n",
       "                \n",
       "                <td id=\"T_077c76be_f2f9_11e7_9818_240a64de810drow8_col1\" class=\"data row8 col1\">\n",
       "                    0.728724\n",
       "                \n",
       "                <td id=\"T_077c76be_f2f9_11e7_9818_240a64de810drow8_col2\" class=\"data row8 col2\">\n",
       "                    0.253244\n",
       "                \n",
       "                <td id=\"T_077c76be_f2f9_11e7_9818_240a64de810drow8_col3\" class=\"data row8 col3\">\n",
       "                    0.366764\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_077c76be_f2f9_11e7_9818_240a64de810d\" class=\"row_heading level3 row9\">\n",
       "                    9\n",
       "                \n",
       "                <td id=\"T_077c76be_f2f9_11e7_9818_240a64de810drow9_col0\" class=\"data row9 col0\">\n",
       "                    0.65959\n",
       "                \n",
       "                <td id=\"T_077c76be_f2f9_11e7_9818_240a64de810drow9_col1\" class=\"data row9 col1\">\n",
       "                    0.728115\n",
       "                \n",
       "                <td id=\"T_077c76be_f2f9_11e7_9818_240a64de810drow9_col2\" class=\"data row9 col2\">\n",
       "                    0.64533\n",
       "                \n",
       "                <td id=\"T_077c76be_f2f9_11e7_9818_240a64de810drow9_col3\" class=\"data row9 col3\">\n",
       "                    0.475732\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "        </tbody>\n",
       "        </table>\n",
       "        "
      ],
      "text/plain": [
       "<pandas.formats.style.Styler at 0x98a20f0>"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 条形图\n",
    "\n",
    "df = pd.DataFrame(np.random.rand(10,4),columns = list('ABCD'))\n",
    "df.style.bar(subset=['A', 'B'], color='#d65f5f', width=100)\n",
    "# width：最长长度在格子的占比"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "        <style  type=\"text/css\" >\n",
       "        \n",
       "        \n",
       "            #T_08541536_f2f9_11e7_8ac7_240a64de810drow0_col0 {\n",
       "            \n",
       "                width:  10em;\n",
       "            \n",
       "                 height:  80%;\n",
       "            \n",
       "                background:  linear-gradient(90deg,#d65f5f 69.23569529384095%, transparent 0%);\n",
       "            \n",
       "                : ;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_08541536_f2f9_11e7_8ac7_240a64de810drow0_col1 {\n",
       "            \n",
       "                width:  10em;\n",
       "            \n",
       "                 height:  80%;\n",
       "            \n",
       "                background:  linear-gradient(90deg,#d65f5f 53.02872303856184%, transparent 0%);\n",
       "            \n",
       "                : ;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_08541536_f2f9_11e7_8ac7_240a64de810drow1_col0 {\n",
       "            \n",
       "                width:  10em;\n",
       "            \n",
       "                 height:  80%;\n",
       "            \n",
       "                : ;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_08541536_f2f9_11e7_8ac7_240a64de810drow1_col1 {\n",
       "            \n",
       "                width:  10em;\n",
       "            \n",
       "                 height:  80%;\n",
       "            \n",
       "                background:  linear-gradient(90deg,#d65f5f 15.952968401363195%, transparent 0%);\n",
       "            \n",
       "                : ;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_08541536_f2f9_11e7_8ac7_240a64de810drow2_col0 {\n",
       "            \n",
       "                width:  10em;\n",
       "            \n",
       "                 height:  80%;\n",
       "            \n",
       "                background:  linear-gradient(90deg,#d65f5f nan%, transparent 0%);\n",
       "            \n",
       "                background-color:  yellow;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_08541536_f2f9_11e7_8ac7_240a64de810drow2_col1 {\n",
       "            \n",
       "                width:  10em;\n",
       "            \n",
       "                 height:  80%;\n",
       "            \n",
       "                background:  linear-gradient(90deg,#d65f5f 83.91322721082197%, transparent 0%);\n",
       "            \n",
       "                : ;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_08541536_f2f9_11e7_8ac7_240a64de810drow3_col0 {\n",
       "            \n",
       "                width:  10em;\n",
       "            \n",
       "                 height:  80%;\n",
       "            \n",
       "                background:  linear-gradient(90deg,#d65f5f nan%, transparent 0%);\n",
       "            \n",
       "                background-color:  yellow;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_08541536_f2f9_11e7_8ac7_240a64de810drow3_col1 {\n",
       "            \n",
       "                width:  10em;\n",
       "            \n",
       "                 height:  80%;\n",
       "            \n",
       "                background:  linear-gradient(90deg,#d65f5f 75.00425537490163%, transparent 0%);\n",
       "            \n",
       "                : ;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_08541536_f2f9_11e7_8ac7_240a64de810drow4_col0 {\n",
       "            \n",
       "                width:  10em;\n",
       "            \n",
       "                 height:  80%;\n",
       "            \n",
       "                background:  linear-gradient(90deg,#d65f5f 50.42948320509824%, transparent 0%);\n",
       "            \n",
       "                : ;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_08541536_f2f9_11e7_8ac7_240a64de810drow4_col1 {\n",
       "            \n",
       "                width:  10em;\n",
       "            \n",
       "                 height:  80%;\n",
       "            \n",
       "                background:  linear-gradient(90deg,#d65f5f 54.44483277408722%, transparent 0%);\n",
       "            \n",
       "                : ;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_08541536_f2f9_11e7_8ac7_240a64de810drow5_col0 {\n",
       "            \n",
       "                width:  10em;\n",
       "            \n",
       "                 height:  80%;\n",
       "            \n",
       "                background:  linear-gradient(90deg,#d65f5f 1.048823137417722%, transparent 0%);\n",
       "            \n",
       "                : ;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_08541536_f2f9_11e7_8ac7_240a64de810drow5_col1 {\n",
       "            \n",
       "                width:  10em;\n",
       "            \n",
       "                 height:  80%;\n",
       "            \n",
       "                background:  linear-gradient(90deg,#d65f5f 100.0%, transparent 0%);\n",
       "            \n",
       "                : ;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_08541536_f2f9_11e7_8ac7_240a64de810drow6_col0 {\n",
       "            \n",
       "                width:  10em;\n",
       "            \n",
       "                 height:  80%;\n",
       "            \n",
       "                background:  linear-gradient(90deg,#d65f5f 62.91320734451104%, transparent 0%);\n",
       "            \n",
       "                : ;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_08541536_f2f9_11e7_8ac7_240a64de810drow6_col1 {\n",
       "            \n",
       "                width:  10em;\n",
       "            \n",
       "                 height:  80%;\n",
       "            \n",
       "                background:  linear-gradient(90deg,#d65f5f 76.32240418395574%, transparent 0%);\n",
       "            \n",
       "                : ;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_08541536_f2f9_11e7_8ac7_240a64de810drow7_col0 {\n",
       "            \n",
       "                width:  10em;\n",
       "            \n",
       "                 height:  80%;\n",
       "            \n",
       "                background:  linear-gradient(90deg,#d65f5f 96.95201846864457%, transparent 0%);\n",
       "            \n",
       "                : ;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_08541536_f2f9_11e7_8ac7_240a64de810drow7_col1 {\n",
       "            \n",
       "                width:  10em;\n",
       "            \n",
       "                 height:  80%;\n",
       "            \n",
       "                background:  linear-gradient(90deg,#d65f5f 5.41059535996635%, transparent 0%);\n",
       "            \n",
       "                : ;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_08541536_f2f9_11e7_8ac7_240a64de810drow8_col0 {\n",
       "            \n",
       "                width:  10em;\n",
       "            \n",
       "                 height:  80%;\n",
       "            \n",
       "                background:  linear-gradient(90deg,#d65f5f 59.48230743956116%, transparent 0%);\n",
       "            \n",
       "                : ;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_08541536_f2f9_11e7_8ac7_240a64de810drow8_col1 {\n",
       "            \n",
       "                width:  10em;\n",
       "            \n",
       "                 height:  80%;\n",
       "            \n",
       "                background:  linear-gradient(90deg,#d65f5f 18.711807256455675%, transparent 0%);\n",
       "            \n",
       "                : ;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_08541536_f2f9_11e7_8ac7_240a64de810drow9_col0 {\n",
       "            \n",
       "                width:  10em;\n",
       "            \n",
       "                 height:  80%;\n",
       "            \n",
       "                background:  linear-gradient(90deg,#d65f5f 100.0%, transparent 0%);\n",
       "            \n",
       "                : ;\n",
       "            \n",
       "            }\n",
       "        \n",
       "            #T_08541536_f2f9_11e7_8ac7_240a64de810drow9_col1 {\n",
       "            \n",
       "                width:  10em;\n",
       "            \n",
       "                 height:  80%;\n",
       "            \n",
       "                : ;\n",
       "            \n",
       "            }\n",
       "        \n",
       "        </style>\n",
       "\n",
       "        <table id=\"T_08541536_f2f9_11e7_8ac7_240a64de810d\" None>\n",
       "        \n",
       "\n",
       "        <thead>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th class=\"blank\">\n",
       "                \n",
       "                <th class=\"col_heading level0 col0\">A\n",
       "                \n",
       "                <th class=\"col_heading level0 col1\">B\n",
       "                \n",
       "                <th class=\"col_heading level0 col2\">C\n",
       "                \n",
       "                <th class=\"col_heading level0 col3\">D\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "        </thead>\n",
       "        <tbody>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_08541536_f2f9_11e7_8ac7_240a64de810d\" class=\"row_heading level3 row0\">\n",
       "                    0\n",
       "                \n",
       "                <td id=\"T_08541536_f2f9_11e7_8ac7_240a64de810drow0_col0\" class=\"data row0 col0\">\n",
       "                    0.685636\n",
       "                \n",
       "                <td id=\"T_08541536_f2f9_11e7_8ac7_240a64de810drow0_col1\" class=\"data row0 col1\">\n",
       "                    0.557271\n",
       "                \n",
       "                <td id=\"T_08541536_f2f9_11e7_8ac7_240a64de810drow0_col2\" class=\"data row0 col2\">\n",
       "                    0.128983\n",
       "                \n",
       "                <td id=\"T_08541536_f2f9_11e7_8ac7_240a64de810drow0_col3\" class=\"data row0 col3\">\n",
       "                    0.493455\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_08541536_f2f9_11e7_8ac7_240a64de810d\" class=\"row_heading level3 row1\">\n",
       "                    1\n",
       "                \n",
       "                <td id=\"T_08541536_f2f9_11e7_8ac7_240a64de810drow1_col0\" class=\"data row1 col0\">\n",
       "                    0.0286531\n",
       "                \n",
       "                <td id=\"T_08541536_f2f9_11e7_8ac7_240a64de810drow1_col1\" class=\"data row1 col1\">\n",
       "                    0.219964\n",
       "                \n",
       "                <td id=\"T_08541536_f2f9_11e7_8ac7_240a64de810drow1_col2\" class=\"data row1 col2\">\n",
       "                    0.0394714\n",
       "                \n",
       "                <td id=\"T_08541536_f2f9_11e7_8ac7_240a64de810drow1_col3\" class=\"data row1 col3\">\n",
       "                    0.657113\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_08541536_f2f9_11e7_8ac7_240a64de810d\" class=\"row_heading level3 row2\">\n",
       "                    2\n",
       "                \n",
       "                <td id=\"T_08541536_f2f9_11e7_8ac7_240a64de810drow2_col0\" class=\"data row2 col0\">\n",
       "                    nan\n",
       "                \n",
       "                <td id=\"T_08541536_f2f9_11e7_8ac7_240a64de810drow2_col1\" class=\"data row2 col1\">\n",
       "                    0.838251\n",
       "                \n",
       "                <td id=\"T_08541536_f2f9_11e7_8ac7_240a64de810drow2_col2\" class=\"data row2 col2\">\n",
       "                    0.0598857\n",
       "                \n",
       "                <td id=\"T_08541536_f2f9_11e7_8ac7_240a64de810drow2_col3\" class=\"data row2 col3\">\n",
       "                    0.548219\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_08541536_f2f9_11e7_8ac7_240a64de810d\" class=\"row_heading level3 row3\">\n",
       "                    3\n",
       "                \n",
       "                <td id=\"T_08541536_f2f9_11e7_8ac7_240a64de810drow3_col0\" class=\"data row3 col0\">\n",
       "                    nan\n",
       "                \n",
       "                <td id=\"T_08541536_f2f9_11e7_8ac7_240a64de810drow3_col1\" class=\"data row3 col1\">\n",
       "                    0.757199\n",
       "                \n",
       "                <td id=\"T_08541536_f2f9_11e7_8ac7_240a64de810drow3_col2\" class=\"data row3 col2\">\n",
       "                    0.169712\n",
       "                \n",
       "                <td id=\"T_08541536_f2f9_11e7_8ac7_240a64de810drow3_col3\" class=\"data row3 col3\">\n",
       "                    0.973893\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_08541536_f2f9_11e7_8ac7_240a64de810d\" class=\"row_heading level3 row4\">\n",
       "                    4\n",
       "                \n",
       "                <td id=\"T_08541536_f2f9_11e7_8ac7_240a64de810drow4_col0\" class=\"data row4 col0\">\n",
       "                    0.507182\n",
       "                \n",
       "                <td id=\"T_08541536_f2f9_11e7_8ac7_240a64de810drow4_col1\" class=\"data row4 col1\">\n",
       "                    0.570154\n",
       "                \n",
       "                <td id=\"T_08541536_f2f9_11e7_8ac7_240a64de810drow4_col2\" class=\"data row4 col2\">\n",
       "                    0.360712\n",
       "                \n",
       "                <td id=\"T_08541536_f2f9_11e7_8ac7_240a64de810drow4_col3\" class=\"data row4 col3\">\n",
       "                    0.166776\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_08541536_f2f9_11e7_8ac7_240a64de810d\" class=\"row_heading level3 row5\">\n",
       "                    5\n",
       "                \n",
       "                <td id=\"T_08541536_f2f9_11e7_8ac7_240a64de810drow5_col0\" class=\"data row5 col0\">\n",
       "                    0.0386054\n",
       "                \n",
       "                <td id=\"T_08541536_f2f9_11e7_8ac7_240a64de810drow5_col1\" class=\"data row5 col1\">\n",
       "                    0.984605\n",
       "                \n",
       "                <td id=\"T_08541536_f2f9_11e7_8ac7_240a64de810drow5_col2\" class=\"data row5 col2\">\n",
       "                    0.775698\n",
       "                \n",
       "                <td id=\"T_08541536_f2f9_11e7_8ac7_240a64de810drow5_col3\" class=\"data row5 col3\">\n",
       "                    0.309116\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_08541536_f2f9_11e7_8ac7_240a64de810d\" class=\"row_heading level3 row6\">\n",
       "                    6\n",
       "                \n",
       "                <td id=\"T_08541536_f2f9_11e7_8ac7_240a64de810drow6_col0\" class=\"data row6 col0\">\n",
       "                    0.625641\n",
       "                \n",
       "                <td id=\"T_08541536_f2f9_11e7_8ac7_240a64de810drow6_col1\" class=\"data row6 col1\">\n",
       "                    0.769192\n",
       "                \n",
       "                <td id=\"T_08541536_f2f9_11e7_8ac7_240a64de810drow6_col2\" class=\"data row6 col2\">\n",
       "                    0.717468\n",
       "                \n",
       "                <td id=\"T_08541536_f2f9_11e7_8ac7_240a64de810drow6_col3\" class=\"data row6 col3\">\n",
       "                    0.354582\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_08541536_f2f9_11e7_8ac7_240a64de810d\" class=\"row_heading level3 row7\">\n",
       "                    7\n",
       "                \n",
       "                <td id=\"T_08541536_f2f9_11e7_8ac7_240a64de810drow7_col0\" class=\"data row7 col0\">\n",
       "                    0.948638\n",
       "                \n",
       "                <td id=\"T_08541536_f2f9_11e7_8ac7_240a64de810drow7_col1\" class=\"data row7 col1\">\n",
       "                    0.124052\n",
       "                \n",
       "                <td id=\"T_08541536_f2f9_11e7_8ac7_240a64de810drow7_col2\" class=\"data row7 col2\">\n",
       "                    0.525165\n",
       "                \n",
       "                <td id=\"T_08541536_f2f9_11e7_8ac7_240a64de810drow7_col3\" class=\"data row7 col3\">\n",
       "                    0.050235\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_08541536_f2f9_11e7_8ac7_240a64de810d\" class=\"row_heading level3 row8\">\n",
       "                    8\n",
       "                \n",
       "                <td id=\"T_08541536_f2f9_11e7_8ac7_240a64de810drow8_col0\" class=\"data row8 col0\">\n",
       "                    0.593085\n",
       "                \n",
       "                <td id=\"T_08541536_f2f9_11e7_8ac7_240a64de810drow8_col1\" class=\"data row8 col1\">\n",
       "                    0.245063\n",
       "                \n",
       "                <td id=\"T_08541536_f2f9_11e7_8ac7_240a64de810drow8_col2\" class=\"data row8 col2\">\n",
       "                    0.578993\n",
       "                \n",
       "                <td id=\"T_08541536_f2f9_11e7_8ac7_240a64de810drow8_col3\" class=\"data row8 col3\">\n",
       "                    0.0695989\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "            <tr>\n",
       "                \n",
       "                <th id=\"T_08541536_f2f9_11e7_8ac7_240a64de810d\" class=\"row_heading level3 row9\">\n",
       "                    9\n",
       "                \n",
       "                <td id=\"T_08541536_f2f9_11e7_8ac7_240a64de810drow9_col0\" class=\"data row9 col0\">\n",
       "                    0.97756\n",
       "                \n",
       "                <td id=\"T_08541536_f2f9_11e7_8ac7_240a64de810drow9_col1\" class=\"data row9 col1\">\n",
       "                    0.0748271\n",
       "                \n",
       "                <td id=\"T_08541536_f2f9_11e7_8ac7_240a64de810drow9_col2\" class=\"data row9 col2\">\n",
       "                    0.616208\n",
       "                \n",
       "                <td id=\"T_08541536_f2f9_11e7_8ac7_240a64de810drow9_col3\" class=\"data row9 col3\">\n",
       "                    0.630743\n",
       "                \n",
       "            </tr>\n",
       "            \n",
       "        </tbody>\n",
       "        </table>\n",
       "        "
      ],
      "text/plain": [
       "<pandas.formats.style.Styler at 0x98bd898>"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 分段式构建样式\n",
    "\n",
    "df = pd.DataFrame(np.random.rand(10,4),columns = list('ABCD'))\n",
    "df['A'][[3,2]] = np.nan\n",
    "df.style.\\\n",
    "    bar(subset=['A', 'B'], color='#d65f5f', width=100).\\\n",
    "    highlight_null(null_color='yellow')"
   ]
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
